Refactored Netscript with Acorns parser. Major rebalancing. Add TIX API. Add round(), purchaseServer().

This commit is contained in:
Daniel Xie
2017-07-13 11:54:29 -05:00
parent 378797e511
commit 222f75d55a
15 changed files with 696 additions and 305 deletions
+14 -1
View File
@@ -48,7 +48,20 @@ Environment.prototype = {
}
return (scope || this).vars[name] = value;
},
setArrayElement: function(name, idx, value) {
var scope = this.lookup(name);
if (!scope && this.parent) {
console.log("Here");
throw new Error("Undefined variable " + name);
}
var arr = (scope || this).vars[name];
if (!(arr.constructor === Array || arr instanceof Array)) {
throw new Error("Variable is not an array: " + name);
}
return (scope || this).vars[name][idx] = value;
},
//Creates (or overwrites) a variable in the current scope
def: function(name, value) {
return this.vars[name] = value;