mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-17 13:13:49 +01:00
MISC: Always add script's earnings to its parent (#1754)
This commit is contained in:
parent
60c4be0496
commit
e3c10e9f0f
@ -330,21 +330,23 @@ Otherwise, this can also occur if you have attempted to launch a script from a t
|
|||||||
|
|
||||||
// Start the script's execution using the correct function for file type
|
// Start the script's execution using the correct function for file type
|
||||||
(isLegacyScript(workerScript.name) ? startNetscript1Script : startNetscript2Script)(workerScript)
|
(isLegacyScript(workerScript.name) ? startNetscript1Script : startNetscript2Script)(workerScript)
|
||||||
// Once the code finishes (either resolved or rejected, doesnt matter), set its
|
// Once the code finishes (either resolved or rejected, doesn't matter), set its
|
||||||
// running status to false
|
// running status to false
|
||||||
.then(function () {
|
.then(function () {
|
||||||
// On natural death, the earnings are transferred to the parent if it still exists.
|
|
||||||
if (parent && !parent.env.stopFlag) {
|
|
||||||
parent.scriptRef.onlineExpGained += runningScriptObj.onlineExpGained;
|
|
||||||
parent.scriptRef.onlineMoneyMade += runningScriptObj.onlineMoneyMade;
|
|
||||||
}
|
|
||||||
killWorkerScript(workerScript);
|
killWorkerScript(workerScript);
|
||||||
workerScript.log("", () => "Script finished running");
|
workerScript.log("", () => "Script finished running");
|
||||||
})
|
})
|
||||||
.catch(function (e) {
|
.catch(function (e) {
|
||||||
handleUnknownError(e, workerScript);
|
handleUnknownError(e, workerScript);
|
||||||
workerScript.log("", () => (e instanceof ScriptDeath ? "Script killed." : "Script crashed due to an error."));
|
|
||||||
killWorkerScript(workerScript);
|
killWorkerScript(workerScript);
|
||||||
|
workerScript.log("", () => (e instanceof ScriptDeath ? "Script killed." : "Script crashed due to an error."));
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
// The earnings are transferred to the parent if it still exists.
|
||||||
|
if (parent && !parent.env.stopFlag) {
|
||||||
|
parent.scriptRef.onlineExpGained += runningScriptObj.onlineExpGained;
|
||||||
|
parent.scriptRef.onlineMoneyMade += runningScriptObj.onlineMoneyMade;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user