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
commit 6a3ffff3ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

@ -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);

@ -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
@ -96,7 +104,7 @@ export class Script {
}
this.filename = filenameElem!.value;
this.server = serverIp;
this.updateRamUsage(otherScripts);
this.updateRamUsage(otherScripts);
this.markUpdated();
}
}