mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-09-19 20:38:42 +02:00
Implemented kill command. UNTESTED, TEST THIS WHEN YOU CAN
This commit is contained in:
parent
8c58710495
commit
7a5a9ccb65
@ -68,4 +68,15 @@ function runScriptsLoop() {
|
||||
setTimeout(runScriptsLoop, 10000);
|
||||
}
|
||||
|
||||
//Queues a script to be killed by settings its stop flag to true. Then, the code will reject
|
||||
//all of its promises recursively, and when it does so it will no longer be running.
|
||||
//The runScriptsLoop() will then delete the script from worker scripts
|
||||
function killWorkerScript(scriptName, serverIp) {
|
||||
for (var i = 0; i < workerScripts.length; i++) {
|
||||
if (workerScripts[i].name == scriptName && workerScripts[i].serverIp == serverIp) {
|
||||
workerScripts[i].env.stopFlag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
runScriptsLoop();
|
@ -270,7 +270,19 @@ var Terminal = {
|
||||
post(Player.getCurrentServer().ip);
|
||||
break;
|
||||
case "kill":
|
||||
//TODO
|
||||
if (commandArray.length != 2) {
|
||||
post("Incorrect usage of kill command. Usage: kill [scriptname]"); return;
|
||||
}
|
||||
|
||||
var scriptName = commandArray[1];
|
||||
for (var i = 0; i < Player.getCurrentServer().runningScripts.length; i++) {
|
||||
if (Player.getCurrentServer().runningScripts[i] == scriptName) {
|
||||
Player.getCurrentServer().runningScripts.splice(i, 1);
|
||||
|
||||
killWorkerScript(scriptName, Player.getCurrentServer().ip);
|
||||
}
|
||||
}
|
||||
post("No such script is running. Nothing to kill");
|
||||
break;
|
||||
case "ls":
|
||||
if (commandArray.length != 1) {
|
||||
|
Loading…
Reference in New Issue
Block a user