mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-24 02:03:01 +02:00
New Hacknet Node Netscript API - initial commit
This commit is contained in:
+23
-10
@@ -211,12 +211,25 @@ function scriptEditorInit() {
|
||||
if (prefix.length === 0) {callback(null, []); return;}
|
||||
var words = [];
|
||||
var fns = NetscriptFunctions(null);
|
||||
for (var name in fns) {
|
||||
for (let name in fns) {
|
||||
if (fns.hasOwnProperty(name)) {
|
||||
words.push({
|
||||
name: name,
|
||||
value: name,
|
||||
});
|
||||
name: name,
|
||||
value: name,
|
||||
});
|
||||
|
||||
//Get functions from namespaces
|
||||
if (name === "bladeburner" || name === "hacknet") {
|
||||
let namespace = fns[name];
|
||||
if (typeof namespace !== "object") {continue;}
|
||||
let namespaceFns = Object.keys(namespace);
|
||||
for (let i = 0; i < namespaceFns.length; ++i) {
|
||||
words.push({
|
||||
name: namespaceFns[i],
|
||||
value: namespaceFns[i],
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
callback(null, words);
|
||||
@@ -465,11 +478,11 @@ function parseOnlyRamCalculate(server, code, workerScript) {
|
||||
}
|
||||
|
||||
// Check if this is one of the special keys, and add the appropriate ram cost if so.
|
||||
if (ref == specialReferenceIF) ram += CONSTANTS.ScriptIfRamCost;
|
||||
if (ref == specialReferenceFOR) ram += CONSTANTS.ScriptForRamCost;
|
||||
if (ref == specialReferenceWHILE) ram += CONSTANTS.ScriptWhileRamCost;
|
||||
if (ref == "hacknetnodes") ram += CONSTANTS.ScriptHacknetNodesRamCost;
|
||||
if (ref == "document" || ref == "window") ram += CONSTANTS.ScriptDomRamCost;
|
||||
if (ref == specialReferenceIF) ram += CONSTANTS.ScriptIfRamCost;
|
||||
if (ref == specialReferenceFOR) ram += CONSTANTS.ScriptForRamCost;
|
||||
if (ref == specialReferenceWHILE) ram += CONSTANTS.ScriptWhileRamCost;
|
||||
if (ref == "hacknet") ram += CONSTANTS.ScriptHacknetNodesRamCost;
|
||||
if (ref == "document" || ref == "window") ram += CONSTANTS.ScriptDomRamCost;
|
||||
|
||||
// Check if this ident is a function in the workerscript env. If it is, then we need to
|
||||
// get its RAM cost. We do this by calling it, which works because the running script
|
||||
@@ -739,7 +752,7 @@ function calculateRamUsage(codeCopy) {
|
||||
}
|
||||
|
||||
//Special case: hacknetnodes array
|
||||
if (codeCopy.includes("hacknetnodes")) {
|
||||
if (codeCopy.includes("hacknet")) {
|
||||
ramUsage += CONSTANTS.ScriptHacknetNodesRamCost;
|
||||
}
|
||||
return ramUsage;
|
||||
|
||||
Reference in New Issue
Block a user