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:
danielyxie
2018-08-30 15:27:47 -05:00
parent 30f8c4a6f0
commit 395fc3b9df
7 changed files with 72 additions and 17 deletions

View File

@@ -659,14 +659,14 @@ getNextHacknetNodeCost
.. js:function:: getNextHacknetNodeCost()
Deprecated (no longer usable). See :doc:`netscripthacknetnodeapi`
Deprecated (no longer usable). See :doc:`netscripthacknetnodeapi`
purchaseHacknetNode
^^^^^^^^^^^^^^^^^^^
.. js:function:: purchaseHacknetNode()
Deprecated (no longer usable). See :doc:`netscripthacknetnodeapi`
Deprecated (no longer usable). See :doc:`netscripthacknetnodeapi`
getPurchasedServerCost
^^^^^^^^^^^^^^^^^^^^^^
@@ -772,6 +772,18 @@ write
is set to "w", then the data is written in "write" mode which means that it will overwrite all existing data on the text file. If *mode* is set to
any other value then the data will be written in "append" mode which means that the data will be added at the end of the text file.
tryWrite
^^^^^^^^
.. js:function:: tryWrite(port, data="")
:param number port: Port to be written to
:param string data: Data to try to write
:returns: True if the data is successfully written to the port, and false otherwise
Attempts to write data to the specified Netscript Port. If the port is full, the data will
not be written. Otherwise, the data will be written normally
read
^^^^
@@ -813,6 +825,17 @@ clear
If the *port/fn* argument is a string, then it specifies the name of a text file (.txt) and will delete all data from that text file.
getPortHandle
^^^^^^^^^^^^^
.. js:function:: getPortHandle(port)
:param number port: Port number
Get a handle to a Netscript Port. See more details here: :ref:`netscript_ports`
**WARNING:** Port Handles only work in :ref:`netscriptjs`. They will not work in :ref:`netscript1`.
rm
^^