Got NetScript working asyhcronously with Promises! Only for loops have been tested though. Still need to test while loops and ifs. While loops should work if the for loops do, idk about if statements though. If statements aren't a high priority right now though

This commit is contained in:
Daniel Xie
2016-11-29 16:56:05 -06:00
parent 1efee3b7d6
commit 77f0c31777
4 changed files with 241 additions and 332 deletions
+1 -20
View File
@@ -147,7 +147,6 @@ var Engine = {
},
/* Main Event Loop */
_scriptUpdateStatusCounter: 0,
idleTimer: function() {
//Get time difference
var _thisUpdate = new Date().getTime();
@@ -155,21 +154,13 @@ var Engine = {
//Divide this by cycle time to determine how many cycles have elapsed since last update
diff = Math.round(diff / Engine._idleSpeed);
Engine._scriptUpdateStatusCounter += diff;
if (diff > 0) {
//Update the game engine by the calculated number of cycles
Engine.updateGame(diff);
Engine._lastUpdate = _thisUpdate;
}
if (Engine._scriptUpdateStatusCounter >= 50) {
console.log("Updating Script Status");
Engine._scriptUpdateStatusCounter = 0;
//Engine.updateScriptStatus();
}
window.requestAnimationFrame(Engine.idleTimer);
},
@@ -226,16 +217,6 @@ var Engine = {
}
},
/* NetScript Web Worker Stuff */
_scriptWebWorker: null,
updateScriptStatus: function() {
Engine._scriptWebWorker.postMessage(
{'type': "Status Update",
'buf1': JSON.stringify(ForeignServers),
'buf2': JSON.stringify(Player)}
)
},
/* Initialization */
init: function() {
//Initialization functions