mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-25 02:32:55 +02:00
Added tryWrite() as a native Netscript function. Updated documentation to reflect the fact that port handles no longer work in Netscript 1.0
This commit is contained in:
+6
-4
@@ -493,10 +493,12 @@ let CONSTANTS = {
|
||||
"World Stock Exchange account and TIX API Access<br>",
|
||||
|
||||
LatestUpdate:
|
||||
"v0.40.3<br>" +
|
||||
"* b1t_flum3.exe program can now be created immediately at Hacking level 1 (rather than hacking level 5)<br>" +
|
||||
"* UI improvements for the character overview panel and the left-hand menu (by mat-jaworski)<br>" +
|
||||
"* Improved the introductory tutorial<br>"
|
||||
`v0.40.3<br>
|
||||
* b1t_flum3.exe program can now be created immediately at Hacking level 1 (rather than hacking level 5)
|
||||
* UI improvements for the character overview panel and the left-hand menu (by mat-jaworski)
|
||||
* Updated documentation to reflect the fact that Netscript port handles (getPortHandle()) only works in NetscriptJS (2.0), NOT Netscript 1.0
|
||||
* Added tryWrite() Netscript function
|
||||
* Improved the introductory tutorial`
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ function iTutorialEvaluateStep() {
|
||||
"written in the Netscript language, a programming language created for " +
|
||||
"this game. <strong style='background-color:#444;'>There are details about the Netscript language in the documentation, which " +
|
||||
"can be accessed in the 'Tutorial' tab on the main navigation menu. I highly suggest you check " +
|
||||
"it out after this tutorial. </strong> For now, just copy " +
|
||||
"it out after this tutorial.</strong> For now, just copy " +
|
||||
"and paste the following code into the script editor: <br><br>" +
|
||||
"while(true) { <br>" +
|
||||
" hack('foodnstuff'); <br>" +
|
||||
|
||||
@@ -1847,6 +1847,25 @@ function NetscriptFunctions(workerScript) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "Invalid argument passed in for write: " + port);
|
||||
}
|
||||
},
|
||||
tryWrite : function(port, data="") {
|
||||
if (workerScript.checkingRam) {
|
||||
return updateStaticRam("tryWrite", CONSTANTS.ScriptReadWriteRamCost);
|
||||
}
|
||||
updateDynamicRam("tryWrite", CONSTANTS.ScriptReadWriteRamCost);
|
||||
if (!isNaN(port)) {
|
||||
port = Math.round(port);
|
||||
if (port < 1 || port > CONSTANTS.NumNetscriptPorts) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "ERROR: tryWrite() called on invalid port: " + port + ". Only ports 1-" + CONSTANTS.NumNetscriptPorts + " are valid.");
|
||||
}
|
||||
var port = NetscriptPorts[port-1];
|
||||
if (port == null || !(port instanceof NetscriptPort)) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "Could not find port: " + port + ". This is a bug contact the game developer");
|
||||
}
|
||||
return port.tryWrite(data);
|
||||
} else {
|
||||
throw makeRuntimeRejectMsg(workerScript, "Invalid argument passed in for tryWrite: " + port);
|
||||
}
|
||||
},
|
||||
read : function(port) {
|
||||
if (workerScript.checkingRam) {
|
||||
return updateStaticRam("read", CONSTANTS.ScriptReadWriteRamCost);
|
||||
|
||||
Reference in New Issue
Block a user