mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-23 06:32:26 +01:00
More bugfixes for failed Netscript code
This commit is contained in:
parent
37a38c1e27
commit
9fa616b61a
@ -7,7 +7,9 @@
|
|||||||
function evaluate(exp, workerScript) {
|
function evaluate(exp, workerScript) {
|
||||||
var env = workerScript.env;
|
var env = workerScript.env;
|
||||||
if (exp == null) {
|
if (exp == null) {
|
||||||
return;
|
return new Promise(function(resolve, reject) {
|
||||||
|
reject("|" + workerScript.serverIp + "|" + workerScript.name + "|Error: NULL expression");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
switch (exp.type) {
|
switch (exp.type) {
|
||||||
case "num":
|
case "num":
|
||||||
@ -168,7 +170,6 @@ function evaluate(exp, workerScript) {
|
|||||||
evaluateProgPromise.then(function(w) {
|
evaluateProgPromise.then(function(w) {
|
||||||
resolve(workerScript);
|
resolve(workerScript);
|
||||||
}, function(e) {
|
}, function(e) {
|
||||||
console.log("Here");
|
|
||||||
workerScript.errorMessage = e.toString();
|
workerScript.errorMessage = e.toString();
|
||||||
reject(workerScript);
|
reject(workerScript);
|
||||||
});
|
});
|
||||||
@ -210,8 +211,9 @@ function evaluate(exp, workerScript) {
|
|||||||
server = AllServers[ip];
|
server = AllServers[ip];
|
||||||
}
|
}
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
resolve("Invalid IP or server hostname passed in");
|
reject("|" + workerScript.serverIp + "|" + workerScript.name + "|Invalid IP or hostname passed into hack() command");
|
||||||
workerScript.scriptRef.log("Cannot hack(). Invalid IP or hostname passed in: " + ip);
|
workerScript.scriptRef.log("Cannot hack(). Invalid IP or hostname passed in: " + ip);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Calculate the hacking time
|
//Calculate the hacking time
|
||||||
@ -221,11 +223,13 @@ function evaluate(exp, workerScript) {
|
|||||||
if (server.hasAdminRights == false) {
|
if (server.hasAdminRights == false) {
|
||||||
workerScript.scriptRef.log("Cannot hack this server (" + server.hostname + ") because user does not have root access");
|
workerScript.scriptRef.log("Cannot hack this server (" + server.hostname + ") because user does not have root access");
|
||||||
reject("|" + workerScript.serverIp + "|" + workerScript.name + "|Script crashed because it did not have root access to " + server.hostname);
|
reject("|" + workerScript.serverIp + "|" + workerScript.name + "|Script crashed because it did not have root access to " + server.hostname);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server.requiredHackingSkill > Player.hacking_skill) {
|
if (server.requiredHackingSkill > Player.hacking_skill) {
|
||||||
workerScript.scriptRef.log("Cannot hack this server (" + server.hostaname + ") because user does not have root access");
|
workerScript.scriptRef.log("Cannot hack this server (" + server.hostaname + ") because user does not have root access");
|
||||||
reject("|" + workerScript.serverIp + "|" + workerScript.name + "|Script crashed because player's hacking skill is not high enough to hack " + server.hostname);
|
reject("|" + workerScript.serverIp + "|" + workerScript.name + "|Script crashed because player's hacking skill is not high enough to hack " + server.hostname);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
workerScript.scriptRef.log("Attempting to hack " + ip + " in " + hackingTime + " seconds");
|
workerScript.scriptRef.log("Attempting to hack " + ip + " in " + hackingTime + " seconds");
|
||||||
@ -278,6 +282,7 @@ function evaluate(exp, workerScript) {
|
|||||||
} else if (exp.func.value == "sleep") {
|
} else if (exp.func.value == "sleep") {
|
||||||
if (exp.args.length != 1) {
|
if (exp.args.length != 1) {
|
||||||
reject("|" + workerScript.serverIp + "|" + workerScript.name + "|Sleep() call has incorrect number of arguments. Takes 1 argument.");
|
reject("|" + workerScript.serverIp + "|" + workerScript.name + "|Sleep() call has incorrect number of arguments. Takes 1 argument.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var sleepTimePromise = evaluate(exp.args[0], workerScript);
|
var sleepTimePromise = evaluate(exp.args[0], workerScript);
|
||||||
|
@ -60,7 +60,7 @@ function PlayerObject() {
|
|||||||
this.faction_rep_mult = 1;
|
this.faction_rep_mult = 1;
|
||||||
|
|
||||||
//Money
|
//Money
|
||||||
this.money = 0;
|
this.money = 1000;
|
||||||
this.total_money = 0; //Total money ever earned
|
this.total_money = 0; //Total money ever earned
|
||||||
this.lifetime_money = 0; //Total money ever earned
|
this.lifetime_money = 0; //Total money ever earned
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user