Merge pull request #630 from jaguilar/ns2_recompile_when_script_write

Recompile scripts when updated via ns.write
This commit is contained in:
danielyxie
2019-06-02 20:56:21 -07:00
committed by GitHub
2 changed files with 10 additions and 1 deletions

View File

@ -1901,6 +1901,7 @@ function NetscriptFunctions(workerScript) {
}
mode === "w" ? script.code = data : script.code += data;
script.updateRamUsage(server.scripts);
script.markUpdated();
} else {
// Write to text file
let txtFile = getTextFile(fn, server);

View File

@ -79,6 +79,14 @@ export class Script {
}
}
/**
* Marks this script as having been updated. It will be recompiled next time something tries
* to exec it.
*/
markUpdated() {
this.module = "";
}
/**
* Save a script from the script editor
* @param {string} code - The new contents of the script