Stargates can be monitored and controlled by computers from
ComputerCraft or OpenComputers using a Stargate
block. There are two versions of this block, depending on which kind of
computer you are using. The interface block should be
placed somewhere underneath the bottom row of ring blocks.
ComputerCraft interface block
Open Computers interface block
Accessing the Interface
|Use peripheral.wrap() with the
appropriate side or peripheral ID, e.g.
|If there is only one stargate
connected to the computer, you can access it as the primary component
of type "stargate":
component = require("component")
Otherwise you will need to access it by its address, which
you can find by using an Analyzer on the interface block, e.g.
sg = component.proxy("6f2a9642-2ab3-482f-930f-812fadafb48e")
The stargate interface peripheral provides the following methods.
Addresses passed as arguments may be either 7 or 9 characters, with or
without hyphens. Addresses returned are always 9 characters
- Returns: state, engaged,
state is one of:
|Operating and ready to dial
|In the process of dialling
|Finished dialling, wormhole
in transient phase
|Wormhole is stable
|Wormhole is shutting down
|Interface not connected to a
engaged is the number of
direction is one of:
||Connection was dialled from
||Connection was dialled from
the other end
- Returns the amount of energy in the gate's internal buffer plus
the buffers of any attached Stargate Power Units. This is the energy
available for the next dialling operation. If the interface is not
connected to a functioning stargate, zero is returned.
- Energy is measured in stargate energy units (SU). Relationships
between SU and other energy units are:
|1 SU = 20 EU
|1 SU = 80 RF
- Returns the amount of energy that would be needed to connect to
the stargate at the given address.
the address of the attached stargate. If the interface is not connected
to a functioning stargate, an empty string is returned.
the address of the connected stargate. If there is no connection, or
the interface is not connected to a functioning stargate, an empty
string is returned.
- Dials the given address.
- Closes any open connection.
- Returns a string indicating the state of the iris: Closed, Opening, Open, Closing. Returns Offline if no iris is
fitted or the interface is not connected to a functioning stargate.
- Closes the iris, if fitted.
- Opens the iris, if fitted.
- sendMessage(arg, ...)
- Sends a message through an open connection to any stargate
interfaces attached to the destination stargate. Any number of
arguments may be passed. The message is delivered to connected
computers as an sgMessageReceived
event. Has no effect if no stargate connection is open.
In the event of an error, methods of the stargate interface return a pair of values nil, error_message. Methods that do not otherwise return any values return true on success.
Prior to SG Craft
version 1.11, stargate methods raised an exception on
error. If you were relying on that, you will now need to check the
result of each interface call for errors. You may find a function like
this useful for wrapping interface calls:
function check(a, b, ...)
if a == nil then
return a, b, ...
Stargate events have the general form
where name is the name of the
event, and source is the
peripheral ID (ComputerCraft) or component address (Open Computers) of
the interface block that the event came from.
|sgDialIn, source, remote address
|An incoming connection has been
|sgDialOut, source, remote address
|An outgoing connection has been
|sgChevronEngaged, source, chevron number, symbol
chevron has been engaged during dialling
|sgStargateStateChange, source, new state, old state
stargate has changed
|sgIrisStateChange, source, new state, old state
iris has changed
|sgMessageReceived, source, arg, ...
|A message was sent from the
connected stargate using the sendMessage
Open Computers Networking
Open Computers wireless network
messages will pass through an open stargate connection. By default, the
message is rebroadcast on the other side with a strength of 50; you can
change this with the wirelessRebroadcastStrength
addition, if there is a stargate interface at each end, and both of
them have a Network Card (non-wireless) installed in the upgrade slot,
wired network messages will be relayed between the two interfaces.
(Note that this only applies to network messages. Messages sent using
the sendMessage method of the stargate interface do not require network cards.)
Some small Lua programs exercising the functions of the interface.
Code as Zip File