mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 01:23:49 +01:00
Added offline properties for Script object
This commit is contained in:
parent
d372ce5980
commit
1a600ad560
@ -69,9 +69,7 @@
|
||||
|
||||
<div id="character-container">
|
||||
<p id="character-info"> </p>
|
||||
</div> <!-- End terminal-container -->
|
||||
|
||||
|
||||
</div> <!-- End character-container -->
|
||||
|
||||
<!-- Always keep the terminal in focus -->
|
||||
<script type="text/javascript">
|
||||
|
@ -10,6 +10,18 @@ function Script() {
|
||||
this.code = "";
|
||||
this.ramUsage = 0;
|
||||
|
||||
/* Properties to calculate offline progress. Only applies for infinitely looping scripts */
|
||||
|
||||
//Time it takes to execute one iteration of the entire script
|
||||
//Each function takes 1 second, plus hacking time plus and sleep commands
|
||||
this.executionTimeMillis = 0;
|
||||
|
||||
//Number of instructions ("lines") in the code. Any call ending in a ;
|
||||
//is considered one instruction. Used to calculate executionTime
|
||||
this.numInstructions = 0;
|
||||
|
||||
//Which servers are hacked in one iteration of the script. May contain duplicates
|
||||
this.serversHacked = [];
|
||||
}
|
||||
|
||||
//Execute the next function in the Script's function queue
|
||||
@ -20,6 +32,10 @@ Script.prototype.executeNext() {
|
||||
(this.functionQueue.shift())();
|
||||
}
|
||||
|
||||
Script.prototype.setCode(code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/* Wrapper object that wraps a function with its arguments.
|
||||
* These objects are pushed onto a Script object's function queue.
|
||||
* The functions can be called with the standard () operator
|
||||
|
@ -39,21 +39,8 @@ var Engine = {
|
||||
|
||||
//Time variables (milliseconds unix epoch time)
|
||||
_lastUpdate: new Date().getTime(),
|
||||
|
||||
_idleSpeed: 200, //Speed (in ms) at which the main loop is updated
|
||||
|
||||
//Display a status update text
|
||||
_lastStatus: null,
|
||||
displayStatusText: function(text) {
|
||||
Engine.Display.statusText.innerHTML = text;
|
||||
|
||||
clearTimeout(Engine._lastStatus);
|
||||
//Wipe status message after 3 seconds
|
||||
Engine._lastStatus = setTimeout(function() {
|
||||
Engine.Display.statusText.innerHTML = "";
|
||||
}, 3000);
|
||||
},
|
||||
|
||||
//Save function
|
||||
saveFile: function() {
|
||||
var tempSaveFile = JSON.stringify(Player);
|
||||
|
Loading…
Reference in New Issue
Block a user