From d2be753513da0973083024b9e831234c5817a2c6 Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Thu, 2 Feb 2023 11:09:33 +0100 Subject: [PATCH] allow clear command in chat --- js/commands.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/js/commands.js b/js/commands.js index 57dc908..a04a0d6 100644 --- a/js/commands.js +++ b/js/commands.js @@ -6,9 +6,15 @@ function runCommand(input) { // Exit current level const modeSplit = chatMode.split(' '); - if (input.toLowerCase().startsWith("exit") && modeSplit[0] !== "default") { - cmd_exit(); - return ""; + if (modeSplit[0] !== "default") { + const lowerIn = input.toLowerCase(); + if (lowerIn.startsWith("exit")) { + cmd_exit(); + return ""; + } else if (lowerIn.startsWith("clear")) { + cmd_clear(); + return ""; + } } // Handle different chat modes @@ -90,10 +96,9 @@ function cmd_clear() { tbDiv.removeChild(tbc[i]); const prelink = document.createElement("a"); - prelink.innerHTML = pretext.original; + prelink.innerHTML = pretext.current; tbDiv.replaceChild(prelink, tbc[1]); - pretext.current = pretext.original; cursorPosition = 0; cursorYOffset = 7;