mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-29 19:13:49 +01:00
Added logging to scripts
This commit is contained in:
parent
be641b19db
commit
e9c2fd46ff
@ -211,7 +211,7 @@ function evaluate(exp, workerScript) {
|
|||||||
}
|
}
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
resolve("Invalid IP or server hostname passed in");
|
resolve("Invalid IP or server hostname passed in");
|
||||||
//TODO LOg...or throw error or something
|
workerScript.scriptRef.log("Cannot hack(). Invalid IP or hostname passed in: " + ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Calculate the hacking time
|
//Calculate the hacking time
|
||||||
@ -219,10 +219,12 @@ function evaluate(exp, workerScript) {
|
|||||||
|
|
||||||
if (server.hasAdminRights == false) {
|
if (server.hasAdminRights == false) {
|
||||||
console.log("Cannot hack server " + server.hostname);
|
console.log("Cannot hack server " + server.hostname);
|
||||||
resolve("Cannot hack");
|
resolve("Cannot hack, no admin rights");
|
||||||
//TODO LOG That it can't be hacked
|
workerScript.scriptRef.log("Cannot hack this server because user does not have root access");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
workerScript.scriptRef.log("Attempting to hack " + ip + " in " + hackingTime + " seconds");
|
||||||
|
|
||||||
var p = new Promise(function(resolve, reject) {
|
var p = new Promise(function(resolve, reject) {
|
||||||
if (env.stopFlag) {reject(workerScript);}
|
if (env.stopFlag) {reject(workerScript);}
|
||||||
console.log("Hacking " + server.hostname + " after " + hackingTime.toString() + " seconds.");
|
console.log("Hacking " + server.hostname + " after " + hackingTime.toString() + " seconds.");
|
||||||
@ -245,6 +247,7 @@ function evaluate(exp, workerScript) {
|
|||||||
Player.hacking_exp += expGainedOnSuccess;
|
Player.hacking_exp += expGainedOnSuccess;
|
||||||
workerScript.scriptRef.onlineExpGained += expGainedOnSuccess;
|
workerScript.scriptRef.onlineExpGained += expGainedOnSuccess;
|
||||||
console.log("Script successfully hacked " + server.hostname + " for $" + moneyGained + " and " + expGainedOnSuccess + " exp");
|
console.log("Script successfully hacked " + server.hostname + " for $" + moneyGained + " and " + expGainedOnSuccess + " exp");
|
||||||
|
workerScript.scriptRef.log("Script successfully hacked " + server.hostname + " for $" + moneyGained + " and " + expGainedOnSuccess + " exp");
|
||||||
resolve("Hack success");
|
resolve("Hack success");
|
||||||
} else {
|
} else {
|
||||||
//Player only gains 25% exp for failure? TODO Can change this later to balance
|
//Player only gains 25% exp for failure? TODO Can change this later to balance
|
||||||
@ -252,6 +255,7 @@ function evaluate(exp, workerScript) {
|
|||||||
workerScript.scriptRef.onlineExpGained += expGainedOnFailure;
|
workerScript.scriptRef.onlineExpGained += expGainedOnFailure;
|
||||||
|
|
||||||
console.log("Script unsuccessful to hack " + server.hostname + ". Gained " + expGainedOnFailure + "exp");
|
console.log("Script unsuccessful to hack " + server.hostname + ". Gained " + expGainedOnFailure + "exp");
|
||||||
|
workerScript.scriptRef.log("Script unsuccessful to hack " + server.hostname + ". Gained " + expGainedOnFailure + "exp");
|
||||||
resolve("Hack failure");
|
resolve("Hack failure");
|
||||||
}
|
}
|
||||||
}, hackingTime * 1000);
|
}, hackingTime * 1000);
|
||||||
@ -275,6 +279,7 @@ function evaluate(exp, workerScript) {
|
|||||||
var sleepTimePromise = evaluate(exp.args[0], workerScript);
|
var sleepTimePromise = evaluate(exp.args[0], workerScript);
|
||||||
sleepTimePromise.then(function(sleepTime) {
|
sleepTimePromise.then(function(sleepTime) {
|
||||||
console.log("Sleep time: " + sleepTime);
|
console.log("Sleep time: " + sleepTime);
|
||||||
|
workerScript.scriptRef.log("Sleeping for " + sleepTime + " milliseconds");
|
||||||
var p = new Promise(function(resolve, reject) {
|
var p = new Promise(function(resolve, reject) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
resolve("foo");
|
resolve("foo");
|
||||||
|
Loading…
Reference in New Issue
Block a user