mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-29 12:27:07 +02:00
Fixed script hack(), should be working now. Changed some numbers to rebalance. Implemented script RAM usage. If a script uses too much ram it will not run (untested)
This commit is contained in:
+25
-1
@@ -5,6 +5,7 @@
|
||||
//Define commands in script editor (ctrl x to close, etc.)
|
||||
$(document).keydown(function(e) {
|
||||
if (Engine.currentPage == Engine.Page.ScriptEditor) {
|
||||
//Ctrl + x
|
||||
if (e.keyCode == 88 && e.ctrlKey) {
|
||||
var filename = document.getElementById("script-editor-filename").value;
|
||||
|
||||
@@ -97,9 +98,24 @@ Script.prototype.saveScript = function() {
|
||||
this.server = Player.currentServer;
|
||||
|
||||
//TODO Calculate/update number of instructions, ram usage, execution time, etc.
|
||||
this.updateNumInstructions();
|
||||
this.updateRamUsage();
|
||||
}
|
||||
}
|
||||
|
||||
//Calculates the number of instructions, which is just determined by number of semicolons)
|
||||
Script.prototype.updateNumInstructions = function() {
|
||||
var numSemicolons = this.code.split(";").length - 1;
|
||||
this.numInstructions = numSemicolons;
|
||||
}
|
||||
|
||||
//Updates how much RAM the script uses when it is running.
|
||||
//Right now, it is determined solely by the number of instructions
|
||||
//Ideally, I would want it to be based on instructions (e.g. hack() costs a lot but others dont)
|
||||
Script.prototype.updateRamUsage = function() {
|
||||
this.ramUsage = this.numInstructions * .2;
|
||||
}
|
||||
|
||||
Script.prototype.toJSON = function() {
|
||||
return Generic_toJSON("Script", this);
|
||||
}
|
||||
@@ -108,4 +124,12 @@ Script.fromJSON = function(value) {
|
||||
return Generic_fromJSON(Script, value.data);
|
||||
}
|
||||
|
||||
Reviver.constructors.Script = Script;
|
||||
Reviver.constructors.Script = Script;
|
||||
|
||||
|
||||
//TODO
|
||||
//Called when the game is loaded. Loads all running scripts (from all servers)
|
||||
//into worker scripts so that they will start running
|
||||
function loadAllRunningScripts() {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user