-
Notifications
You must be signed in to change notification settings - Fork 0
Node API
The Node API is used to interact with objects and peripherals that can be connected to the computer using nodes. Computers have input and output nodes alike, but it's treated as one continuous line of ports. For example, ports 0 - 3 can represent input nodes, and ports 4 - 6 can represent output nodes. Yet ports 0 - 6 all represent nodes. When a peripheral is connected to any port, the computer will automatically register it. If the peripheral is from this mod, then it registers with a specific name, such as "monitor" or "printer." However, if the peripheral is not from my mod, but rather, from the game itself (or any other mod that adds in wire-able objects), then the peripheral will be registered as type "primitive." As such, you can only use primitive methods, such as setting output and getting input to interact with said peripheral (which should be fine in most cases).
Returns: table NodeConnections
NodeConnections is a table of strings which represent the type of peripheral connected, indexed by the port occupied by said peripheral. Note: Even though it's indexed by number, it's better to use pairs() with this table as some number indexes might be skipped.
Returns: number Width, number Height
This goes through the list of input and output nodes. If it finds the desired peripheral type, it returns the port of the node.
Returns: string peripheralType
Returns the peripheral type at Port.
Returns: number MaxInputNodes
Returns the maximum port used for input. The minimum port used for input is always 0.
Returns: number MaxPort
Returns the maximum port number addressable. The output port range is MaxInputNodes + 1 to MaxPort.
Returns: boolean Success
If the peripheral at the given output port is of type "primitive," then this function will attempt to turn said primitive on or off depending on the activated value given. Will return true on success.
Returns: boolean Activated
If the peripheral at the given input port is of type "primitive," then this function will attempt to get input from said primitive. On success, it returns a boolean.
If the peripheral at the given port is not of type primitive, then this function will call a function directly from said peripheral. If the given functionName exists, then it will return any return values the function may have.
Note: If functionName is "getDriver" then it will return a table of functions. This is the preferred method to use if you plan on invoking functions from the peripheral multiple times.
Returns: string Address
Returns the UUID of the peripheral (assuming it isn't a primitive) in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.