Added Callback function to installAugmentations(). Implemented Source-File 5. Added player-defined functions to Netscript (not thoroughly tested). Began working on Hacking Mission Enemy 'AI'

This commit is contained in:
danielyxie
2017-09-29 10:02:33 -05:00
parent 1233d487d9
commit 26fe9eb519
11 changed files with 5230 additions and 4892 deletions
+9 -2
View File
@@ -12,7 +12,6 @@ import {parse} from "../utils/acorn.js";
import {dialogBoxCreate} from "../utils/DialogBox.js";
import {compareArrays, printArray} from "../utils/HelperFunctions.js";
function WorkerScript(runningScriptObj) {
this.name = runningScriptObj.filename;
this.running = false;
@@ -93,7 +92,7 @@ function runScriptsLoop() {
if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == false) {
try {
var ast = parse(workerScripts[i].code);
//console.log(ast);
console.log(ast);
} catch (e) {
console.log("Error parsing script: " + workerScripts[i].name);
dialogBoxCreate("Syntax ERROR in " + workerScripts[i].name + ":<br>" + e);
@@ -180,6 +179,14 @@ function addWorkerScript(runningScriptObj, server) {
}
var ramUsage = runningScriptObj.scriptRef.ramUsage * threads
* Math.pow(CONSTANTS.MultithreadingRAMCost, threads-1);
var ramAvailable = server.maxRam - server.ramUsed;
if (ramUsage > ramAvailable) {
dialogBoxCreate("Not enough RAM to run script " + runningScriptObj.filename + " with args " +
printArray(runningScriptObj.args) + ". This likely occurred because you re-loaded " +
"the game and the script's RAM usage increased (either because of an update to the game or " +
"your changes to the script.)");
return;
}
server.ramUsed += ramUsage;
//Create the WorkerScript