mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-24 10:12:53 +02:00
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:
+1
-20
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user