From: Lock l00p Date: Sat, 30 Sep 2023 02:02:58 +0000 (+0000) Subject: Added Javascript Terminal support (supposedly) X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7fcda3d4d551a24c4164811d2fc503f15ce67d69;p=xonotic%2Fxonotic.git Added Javascript Terminal support (supposedly) --- diff --git a/misc/buildfiles/emscripten/prejs.js b/misc/buildfiles/emscripten/prejs.js index cf84adb3..836974aa 100644 --- a/misc/buildfiles/emscripten/prejs.js +++ b/misc/buildfiles/emscripten/prejs.js @@ -1,8 +1,18 @@ //current command in ascii decimal let currentcmd = [0,0,0] let cmditerate = 0 -runcmd = function() {} -Module['arguments'] = "-xonotic" +console.log("Run Terminal Commands by running cmd(\"command to run here\")") +cmd = function(input){ + for (let i = 0; i < input.length; i++){ + + currentcmd[i] = input.charCodeAt(i) + + } + return 0 +} +Module['arguments'] = ["-xonotic"] +//pipes output to console +Module['print'] = function(text){console.log(text)} Module['preRun'] = function(){ function stdin(){ //if current command is default, it just returns 0, code for null @@ -10,12 +20,12 @@ Module['preRun'] = function(){ return 0 } //it iterates through the cmd - cmditerate = cmditerate + 1; - if(cmditerate - 1 > currentcmd.length - 1) {currentcmd = [0,0,0]; return 0} + cmditerate++; + if(cmditerate - 1 > currentcmd.length - 1) {currentcmd = [0,0,0]; return 10} return currentcmd[cmditerate - 1] }; - var stdout = null; + var stdout = null; var stderr = null; FS.init(stdin,stdout,stderr); } \ No newline at end of file