Network
A network object.
-- Handles an individual reactor subnet
local function handleReactor(network: Network)
-- Get all of the relevant parts relative to the reactor subnet
local reactor = network:GetPart("Reactor")
local polysilicon = network:GetPart("Polysilicon")
local dispenser = network:GetPart("Dispenser")
-- stuff
end
-- Handles all reactors on a subnet full of reactor modules
local function handleReactors(network: Network)
for _, port in network:GetPorts() do
-- Handle the reactor on the subnet
handleReactor(network:GetSubnet(port))
end
end
-- Handles the reactor modules on Port 1
handleReactors(Network:GetSubnet(1))
GetHistory(self) → history
Returns a list of all objects that have been traversed by the network. Note this makes a copy of the internal state and is therefore modifying it does not affect the network itself whatsoever.
It has no parameters.
The history return is a dictionary with keys that are PilotObject
s and values that are true
s.
GetPart(self, className) → object
The className parameter is a string
. It can also be nil
.
The object return is a PilotObject
. It can also be nil
.
GetPartFromPort(self, port, className) → object
The parameters for GetPartFromPort
are as follows:
- The port parameter is a
PortLike
. It can also benil
. - The className parameter is a
string
. It can also benil
.
The object return is a PilotObject
. It can also be nil
.
GetParts(self, className) → objects
The className parameter is a string
. It can also be nil
.
The objects return is an array of a PilotObject
s.
GetPartsFromPort(self, port, className) → objects
The parameters for GetPartsFromPort
are as follows:
- The port parameter is a
PortLike
. It can also benil
. - The className parameter is a
string
. It can also benil
.
The objects return is an array of a PilotObject
s.
GetPort(self, port) → objects
The port parameter is a PortLike
. It can also be nil
.
The objects return is an array of a Port
s.
GetPorts(self, port) → objects
The port parameter is a PortLike
. It can also be nil
.
The objects return is an array of a Port
s.
GetSubnet(self, port) → subnet
Creates a new network with its root set to the specified Port
.
The port parameter is a PortLike
. It can also be nil
.
The subnet return is a Network
.
__index
It is of the type Network
.
new(rootParts, parentNetwork) → network
This function is volatile and may be subject to change as it is primarily for internal use.
The parameters for new
are as follows:
- The rootParts parameter is an array of objects to be the roots of the network It is an array of a
PilotObject
s. - The parentNetwork parameter is you can use this to make a new network that will never explore along the path that was taken by the network you pass. It is a
Network
. It can also benil
.
The network return is a Network
.
Luau Type
This is the luau type for Network
. It may help clear up mistranslations from the raw data to the wiki page (as it is an automatic process).
export type Network = {
GetPort: (self: Network, port: PortLike?) -> ({ Port }),
GetPartsFromPort: (self: Network, port: PortLike?, className: string?) -> ({ PilotObject }),
GetPart: (self: Network, className: string?) -> (PilotObject?),
GetPartFromPort: (self: Network, port: PortLike?, className: string?) -> (PilotObject?),
GetSubnet: (self: Network, port: PortLike?) -> (Network),
GetParts: (self: Network, className: string?) -> ({ PilotObject }),
GetHistory: (self: Network) -> ({
[PilotObject]: true,
}),
GetPorts: (self: Network, port: PortLike?) -> ({ Port }),
__index: Network,
new: (rootParts: { PilotObject }, parentNetwork: Network?) -> (Network),
}