mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-25 02:32:55 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user