diff --git a/css/menupages.css b/css/menupages.css
index 0ec027941..79a3c49dc 100644
--- a/css/menupages.css
+++ b/css/menupages.css
@@ -23,11 +23,11 @@
#script-editor-container {
position: fixed;
padding-top: 10px;
- padding-left: 10px;
height: 100%;
margin-left: 10%;
- width: 75%;
+ width: 99%;
color: #66ff33;
+ overflow-y: scroll;
}
#script-editor-filename-tag {
@@ -36,14 +36,12 @@
float: left;
}
-#script-editor-save-and-close-button {
- float: right;
- display: inline-block;
-}
-
+#script-editor-save-and-close-button,
#script-editor-netscript-doc-button {
float: right;
display: inline-block;
+ width: 50%;
+ margin-right: 25%;
}
#script-editor-netscript-doc-warning {
@@ -58,9 +56,9 @@
float: left;
resize: none;
color: #66ff33;
- width: 100%;
- margin: 4px;
- padding: 4px;
+ width: 75%;
+ margin: 10px;
+ padding: 5px;
border: 2px solid white;
-webkit-box-shadow:
@@ -81,10 +79,10 @@
#script-editor-text {
color: #66ff33;
- width: 100%;
+ width: 75%;
height: 100%;
- margin: 4px;
- padding: 4px;
+ margin: 10px;
+ padding: 5px;
border: 2px solid white;
-webkit-box-shadow:
diff --git a/index.html b/index.html
index ee64dfb49..3b30df5e3 100644
--- a/index.html
+++ b/index.html
@@ -152,6 +152,7 @@
+
diff --git a/src/Constants.js b/src/Constants.js
index 317838987..20e15606c 100644
--- a/src/Constants.js
+++ b/src/Constants.js
@@ -198,13 +198,18 @@ CONSTANTS = {
"section of this 'Tutorial' page.
Running a script requires RAM. The more complex a script is, the more RAM " +
"it requires to run. Scripts can be run on any server you have root access to.
" +
"Here are some Terminal commands that are useful when working with scripts:
" +
- "free - Shows the current server's RAM usage
" +
+ "free - Shows the current server's RAM usage and availability
" +
"kill [script] - Stops a script that is running
" +
+ "mem [script] - Check how much RAM a script requires to run
" +
"nano [script] - Create/Edit a script
" +
"ps - Displays all scripts that are actively running on the current server
" +
"run [script] - Run a script
" +
"tail [script] - Displays a script's logs
" +
- "top - Displays all active scripts and their RAM usage
",
+ "top - Displays all active scripts and their RAM usage
" +
+ "Note that because of the way the Netscript interpreter is implemented, " +
+ "whenever you reload or re-open the game all of the scripts that you are running will " +
+ "start running from the BEGINNING of the code. The game does not keep track of where exactly " +
+ "the execution of a script is when it saves/loads.
",
TutorialNetscriptText: "Netscript is a very simple programming language implemented for this game. The language has " +
"your basic programming constructs and several built-in commands that are used to hack.
" +
" Variables and data types
" +
@@ -250,6 +255,13 @@ CONSTANTS = {
"relaysmtp(hostname/ip)
Run relaySMTP.exe on the target server. relaySMTP.exe must exist on your home computer
Example: relaysmtp('foodnstuff');
" +
"httpworm(hostname/ip)
Run HTTPWorm.exe on the target server. HTTPWorm.exe must exist on your home computer
Example: httpworm('foodnstuff');
" +
"sqlinject(hostname/ip)
Run SQLInject.exe on the target server. SQLInject.exe must exist on your home computer
Example: sqlinject('foodnstuff');
" +
+ "run(script)
Run a script as a separate process. The argument that is passed in is the name of the script as a string. This function can only " +
+ "be used to run scripts located on the same server. Returns true if the script is successfully started, and false otherwise. Requires a significant amount " +
+ "of RAM to run this command.
Example: run('hack-foodnstuff.script');
The example above will try and launch the 'hack-foodnstuff.script' script on " +
+ "the current server, if it exists.
" +
+ "getHackingLevel()
Returns the Player's current hacking level
" +
+ "getServerMoneyAvailable(hostname/ip)
Returns the amount of money available on a server. The argument passed in must be a string with either the " +
+ "hostname or IP of the target server.
Example: getServerMoneyAvailable('foodnstuff');
" +
"While loops
" +
"A while loop is a control flow statement that repeatedly executes code as long as a condition is met.
" +
"while ([cond]) {
[code]
}
" +
@@ -267,7 +279,21 @@ CONSTANTS = {
"of the for loop. The following example shows code that will do the same thing as the while loop example above, " +
"except using a for loop instead:
" +
"for (i = 0; i < 10; i = i+1) {
hack('foodnstuff');
};
" +
- " If statements
",
+ " If statements
" +
+ "If/Elif/Else statements are conditional statements used to perform different actions based on different conditions:
" +
+ "if (condition1) {
code1
} elif (condition2) {
code2
} else {
" +
+ " code3
}
" +
+ "In the code above, first condition1 will be checked. If this condition is true, then code1 will execute and the " +
+ "rest of the if/elif/else statement will be skipped. If condition1 is NOT true, then the code will then go on to check " +
+ "condition2. If condition2 is true, then code2 will be executed, and the rest of the if/elif/else statement " +
+ "will be skipped. If none of the conditions are true, then the code within the else block (code3) will be executed. " +
+ "Note that a conditional statement can have any number of elif statements.
" +
+ "Example:
" +
+ "if(getServerMoneyAvailable('foodnstuff') > 200000) {
hack('foodnstuff');
" +
+ "} else {
grow('foodnstuff');
};
" +
+ "The code above will use the getServerMoneyAvailable() function to check how much money there is on the 'foodnstuff' server. " +
+ "If there is more than $200,000, then it will try to hack that server. If there is $200,000 or less on the server, " +
+ "then the code will call grow('foodnstuff') instead and add more money to the server.
",
TutorialTravelingText:"There are six major cities in the world that you are able to travel to:
" +
" Aevum
" +
diff --git a/src/HacknetNode.js b/src/HacknetNode.js
index e9b926c11..0d0f42a9a 100644
--- a/src/HacknetNode.js
+++ b/src/HacknetNode.js
@@ -16,12 +16,13 @@ HacknetNode.prototype.updateMoneyGainRate = function() {
//How much extra $/s is gained per level
var gainPerLevel = CONSTANTS.HacknetNodeMoneyGainPerLevel;
- //Each CPU core doubles the speed. Every 1GB of ram adds 20% increase
+ //Each CPU core doubles the speed. Every 1GB of ram adds 15% increase
this.moneyGainRatePerSecond = (this.level * gainPerLevel) *
- Math.pow(1.2, this.ram-1) *
+ Math.pow(1.15, this.ram-1) *
this.numCores * Player.hacknet_node_money_mult;
if (isNaN(this.moneyGainRatePerSecond)) {
- throw new Error("Money gain rate calculated for Hacknet Node is NaN");
+ this.moneyGainRatePerSecond = 0;
+ dialogBoxCreate("Error in calculating Hacknet Node production. Please report to game developer");
}
updateTotalHacknetProduction();
diff --git a/src/NetscriptEvaluator.js b/src/NetscriptEvaluator.js
index ee18b1ee8..0edc62139 100644
--- a/src/NetscriptEvaluator.js
+++ b/src/NetscriptEvaluator.js
@@ -351,8 +351,8 @@ function evaluate(exp, workerScript) {
reject("|" + workerScript.serverIp + "|" + workerScript.name + "|grow() call has incorrect number of arguments. Takes 1 argument");
}
var ipPromise = evaluate(exp.args[0], workerScript);
-
ipPromise.then(function(ip) {
+ if (env.stopFlag) {reject(workerScript);}
var server = getServer(ip);
if (server == null) {
reject("|" + workerScript.serverIp + "|" + workerScript.name + "|Invalid IP or hostname passed into grow() command");
@@ -393,6 +393,7 @@ function evaluate(exp, workerScript) {
}
var ipPromise = evaluate(exp.args[0], workerScript);
ipPromise.then(function(ip) {
+ if (env.stopFlag) {reject(workerScript);}
var server = getServer(ip);
if (server == null) {
reject("|" + workerScript.serverIp + "|" + workerScript.name + "|Invalid IP or hostname passed into nuke() command");
@@ -438,6 +439,7 @@ function evaluate(exp, workerScript) {
}
var ipPromise = evaluate(exp.args[0], workerScript);
ipPromise.then(function(ip) {
+ if (env.stopFlag) {reject(workerScript);}
var server = getServer(ip);
if (server == null) {
reject("|" + workerScript.serverIp + "|" + workerScript.name + "|Invalid IP or hostname passed into brutessh() command");
@@ -479,6 +481,7 @@ function evaluate(exp, workerScript) {
}
var ipPromise = evaluate(exp.args[0], workerScript);
ipPromise.then(function(ip) {
+ if (env.stopFlag) {reject(workerScript);}
var server = getServer(ip);
if (server == null) {
reject("|" + workerScript.serverIp + "|" + workerScript.name + "|Invalid IP or hostname passed into ftpcrack() command");
@@ -520,6 +523,7 @@ function evaluate(exp, workerScript) {
}
var ipPromise = evaluate(exp.args[0], workerScript);
ipPromise.then(function(ip) {
+ if (env.stopFlag) {reject(workerScript);}
var server = getServer(ip);
if (server == null) {
reject("|" + workerScript.serverIp + "|" + workerScript.name + "|Invalid IP or hostname passed into relaysmtp() command");
@@ -561,6 +565,7 @@ function evaluate(exp, workerScript) {
}
var ipPromise = evaluate(exp.args[0], workerScript);
ipPromise.then(function(ip) {
+ if (env.stopFlag) {reject(workerScript);}
var server = getServer(ip);
if (server == null) {
reject("|" + workerScript.serverIp + "|" + workerScript.name + "|Invalid IP or hostname passed into relaysmtp() command");
@@ -602,6 +607,7 @@ function evaluate(exp, workerScript) {
}
var ipPromise = evaluate(exp.args[0], workerScript);
ipPromise.then(function(ip) {
+ if (env.stopFlag) {reject(workerScript);}
var server = getServer(ip);
if (server == null) {
reject("|" + workerScript.serverIp + "|" + workerScript.name + "|Invalid IP or hostname passed into sqlinject() command");
@@ -638,7 +644,6 @@ function evaluate(exp, workerScript) {
reject(e);
});
} else if (exp.func.value == "run") {
- console.log("run() called");
if (exp.args.length != 1) {
reject("|"+workerScript.serverIp+"|"+workerScript.name+"|run() call has incorrect number of arguments. Takes 1 argument");
}
@@ -661,12 +666,12 @@ function evaluate(exp, workerScript) {
reject(e);
});
} else if (exp.func.value == "getHackingLevel") {
- console.log("getHackingLevel called");
if (exp.args.length != 0) {
reject("|"+workerScript.serverIp+"|"+workerScript.name+"|getHackingLevel() call has incorrect number of arguments. Takes 0 arguments");
}
setTimeout(function() {
- console.log("About to resolve getHackingLevel");
+ Player.updateSkillLevels();
+ workerScript.scriptRef.log("getHackingLevel() returned " + Player.hacking_skill);
resolve(Player.hacking_skill);
}, CONSTANTS.CodeInstructionRunTime);
} else if (exp.func.value == "getServerMoneyAvailable") {
@@ -682,6 +687,7 @@ function evaluate(exp, workerScript) {
workerScript.scriptRef.log("Cannot getServerMoneyAvailable(). Invalid IP or hostname passed in: " + ip);
return;
}
+ workerScript.scriptRef.log("getServerMoneyAvailable() returned " + server.moneyAvailable);
resolve(server.moneyAvailable);
}, CONSTANTS.CodeInstructionRunTime);
}, function(e) {
@@ -926,12 +932,15 @@ function apply_op(op, a, b) {
//Run a script from inside a script using run() command
function runScriptFromScript(server, scriptname, workerScript) {
return new Promise(function(resolve, reject) {
+ var env = workerScript.env;
+ if (env.stopFlag) {reject(workerScript);}
setTimeout(function() {
//Check if the script is already running
for (var i = 0; i < server.runningScripts.length; ++i) {
if (server.runningScripts[i] == scriptname) {
workerScript.scriptRef.log(scriptname + " is already running on " + server.hostname);
resolve(false);
+ return;
}
}
@@ -957,6 +966,7 @@ function runScriptFromScript(server, scriptname, workerScript) {
server.runningScripts.push(script.filename); //Push onto runningScripts
addWorkerScript(script, server);
resolve(true);
+ return;
}
}
}
diff --git a/src/NetscriptWorker.js b/src/NetscriptWorker.js
index 4f57bb201..1076ced86 100644
--- a/src/NetscriptWorker.js
+++ b/src/NetscriptWorker.js
@@ -31,7 +31,7 @@ function runScriptsLoop() {
if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == false) {
try {
var ast = Parser(Tokenizer(InputStream(workerScripts[i].code)));
- console.log(ast);
+ //console.log(ast);
} catch (e) {
dialogBoxCreate("Syntax ERROR in " + workerScripts[i].name + ":", e, "", "");
workerScripts[i].env.stopFlag = true;