Skip to content

Stargate API

This section of documentation covers all functions associated with Stargate. To start communication between computer and Stargate, its neccesarry to connect these 2 devices:

  • Wired modem must be placed on any side (except the side where event horizon is created) of stargate base block
  • Wired modem must be placed on any side (except screen) of computer
  • These wired modems must be connected with a networking cables
  • Both wired modems need to be actived by right click - inactive modem has black connector, active has red connector

After activation, a message will be written to the chat as follows:

Peripheral id_int connected to network
id - name of device
int - numerical network device ID (used in peripheral.wrap)

To use the stargate functions, a little programming is required, for example:

without specify stargate network ID:
local sg = peripheral.find("stargate")

with specified stargate network ID:
local sg = peripheral.wrap("stargate_<id>")

This is how a stargate method can be called:

script.lua
local sg = peripheral.find("stargate")
local success, status, initiating = sg.getGateStatus();
--[[
success will store true/false
status will store gate's status
initiating will be true when open gate is outgoing
]]--

Functions that will give you generic informations about the stargate.

Gets what kind of stargate is connected to the computer Returns:

  • gateType : String - [“MilkyWay”, “Movie”, “Tollan”, “Pegasus”, “Universe”, “Orlin’s”, …]

Gets the type glyphs used by the gate when dialing Returns:

  • glyphType : String - [“jsg:milkyway”, “jsg:pegasus”, “jsg:universe”, …]

Gets a list of valid symbols for the connected gate Returns:

  • glyphs : String[] - A list of glyph names

Gets the current status of the gate Returns:

  • success : Boolean - True if no error occurred during processing, otherwise false
  • status : String - [“idle”, “dialing”, “dialing_computer”, “dialing_remote”, “open”, “unstable_opening”, “unstable_closing”, “failing”, “resetting”, “incoming”]
  • initiating : Boolean - Optional when status is “open”: True when outgoing wormhole otherwise false

Gets the amount of time the gate has been open for Returns:

  • success : Boolean - True if no error occurred during processing, otherwise false
  • response : String - [“stargate_time”, “stargate_not_connected”]
  • minutes : Int - Optional when status is “stargate_time”: return how long stargate is active - minutes part
  • seconds : Int - Optional when status is “stargate_time”: return how long stargate is active - seconds part

Returns the number of glyphs needed to dial the address Parameters:

  • address : Table - table with symbols name or IDs

Returns:

  • success : Boolean - True if no error occurred during processing, otherwise false
  • response : String - [“not_merged”, “address_malformed”, “gate_not_found”, “symbols_needed”]
  • symbolsCount : Int - Optional when response is “symbols_needed”: minimal symbols to dial include PoO

Returns all local stargate address system addresses Returns:

  • addressMap : Table - Table with stargate addresses for each symbol typ

Returns current entered glyphs in stargate buffer Returns:

  • address : Table - Table with dialed symbols

getNearbyGates(gateType, ignoreGateType, checkAddressAndEnergy) ★

Section titled “getNearbyGates(gateType, ignoreGateType, checkAddressAndEnergy) ★”

Returns stargates in nearby radius Parameters:

  • gateType : String - Search for specific stargate type
  • ignoreGateType : Boolean - Ignore 1st parameter
  • checkAddressAndEnergy : Boolean - When true return only dialable stargates oterwise return all nearby gates

Returns:

  • success : Boolean - True if no error occurred during processing, otherwise false
  • response : String - [“gate_not_merged”, “success”]
  • gates : Table - Table with available gates, theire addresses and symbols required to dial
Returns current glyph under top chevron

Returns:

  • success : Boolean - True if no error occurred during processing, otherwise false

If success is true then:

  • symbolID : Int - SymbolID
  • symbolName : String - English name of the symbol
  • symbolAngle : Double - Position of symbol on glyph ring - angle in degrees
  • isOrigin : Boolean - True if glyph is Point of Origin otherwise false
  • ringAngle : Double - Angle of stargate ring
Returns angle of the glyph ring

Returns:

  • success : Boolean - False when connected gate is pegasus stargate otherwise true
  • angle : Double - Optional if success is true: angle of glyph ring in degrees

Returns if the stargate is spinning Returns:

  • movement : Boolean - True when stargate glyph ring is spinning
  • ringVelocity : Double - Speed of glyph ring (deg/tick)

Returns chevron status Parameters:

  • index : Int - Selection of chevron [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] (while 9 is the top chevron)

Returns:

  • success : Boolean - True if no error occurred during processing, otherwise false
  • response : String - [“stargate_not_merged”, “chevron_not_found”, “chevron_status”]
  • isOpen : Boolean - True when chevron is open otherwise false
  • chevronState : Boolean - True when chevron is activated otherwise false

Functions that will return informations about energy storage of the stargate.

Formerly getCapacitorsInstalled()

Returns the amount of Energy Crystals installed in the Stargate Returns:

  • crystalsCount : Int - 0~3, nil in case when stargate is not merged

Returns the amount of energy stored by the Stargate Returns:

  • energy : Long - Amount of energy stored in FE

Returns the electrical capacity of the Stargate Returns:

  • maxEnergy : Long - Amount of energy that can be stored i.e. capacity in FE

Returns the amount of energy needed to dial an address Parameters:

  • address : Table - an address of a stargate - names or glyphIds, with or without the Point of Origin glyph

Returns:

  • success : Boolean - True if no error occurred during processing, otherwise false
  • response : String - [“not_merged”, “address_malformed”, “energy_map”]
  • energyMap : Table - Optional when response is “energy_map”: contain 3 entries: {open, keepAlive, canOpen}

Function that operates the gate’s dialing sequence.

Dials a full address, including Point of Origin Parameters:

  • address : Table - an address to dial - names or glyphIds, with the Point of Origin glyph

Returns:

  • success : Boolean - True if no error occurred during processing, otherwise false
  • response : String - [“stargate_failure_not_merged”, “stargate_failure_busy”, “stargate_failure_not_empty”, “input_address_malformed”, “dial_begun”]
  • readableResponse : String - Readable response

Throws:

  • bad argument (symbol name/index invalid) : IllegalArgumentException - Thown when bad symbol is input inside the address
Engage symbol under Top chevron

Returns:

  • success : Boolean - True if no error occurred during processing, otherwise false
  • response : String - [“stargate_not_merged”, “stargate_busy”, “chevron_engage_error”, “chevron_engaged”]
  • readableResponse : String - Readable response

Aborts the active dialing sequence, resetting the gate to idle Returns:

  • success : Boolean - True if no error occurred during processing, otherwise false
  • response : String - [“stargate_failure_not_merged”, “stargate_aborting_failed”, “stargate_aborting”]
  • readableResponse : String - Readable response

Attempts to make a connection to the receiving gate and open a wormhole Returns:

  • success : Boolean - True if no error occurred during processing, otherwise false
  • response : String - [“stargate_failure_not_merged”, “stargate_failure_opening”, “stargate_failure_busy”, “stargate_engage”]
  • readableResponse : String - If response is not “stargate_engage”: Readable response

Attempts to close the wormhole Returns:

  • success : Boolean - True if no error occurred during processing, otherwise false
  • response : String - [“stargate_failure_not_merged”, “stargate_failure_wrong_end”, “stargate_failure_not_open”, “stargate_disengage”]
  • readableResponse : String - Readable response

Spins the stargate’s ring Parameters:

  • counterClockwise : Boolean - Optional; if true, spins the ring counter clockwise

Returns:

  • success : Boolean - True if no error occurred during processing, otherwise false
  • response : String - [“stargate_not_merged”, “stargate_busy”, “stargate_ring_already_spinning”, “stargate_locked”, “stargate_ring_spin”]
  • readableResponse : String - Readable response

Stops the stargate’s ring Returns:

  • success : Boolean - True if no error occurred during processing, otherwise false
  • response : String - [“stargate_not_merged”, “stargate_busy”, “stargate_ring_not_spinning”, “stargate_ring_spin_stop”]
  • readableResponse : String - Readable response

Spins the ring and engages the symbol Parameters:

  • symbol : Int|String - Symbol ID or english name (for point of origins “Point Of Origin” is also accepted)

Returns:

  • success : Boolean - True if no error occurred during processing, otherwise false
  • response : String - [“stargate_failure_not_merged”, “stargate_failure_busy”, “stargate_failure_full”, “stargate_spin”]
  • readableResponse : String - Readable response

Throws:

  • bad argument (symbol name/index invalid) : IllegalArgumentException - Thown when bad symbol is input

Functions that operate iris.

Toggles the stargate’s iris/shield

Returns:

  • success : Boolean - True if no error occurred during processing, otherwise false
  • response : String - [“stargate_iris_missing”, “stargate_iris_error_mode”, “stargate_iris_not_power”, “stargate_iris_busy”, “stargate_iris_toggled”]
  • readableResponse : String - Readable response

Returns current iris/shield state Returns:

  • state : String - [“OPENED”, “CLOSED”, “OPENING”, “CLOSING”, “ERROR”]

Returns attached iris/shield type Returns:

  • type : String - [“NULL”, “IRIS_TITANIUM”, “IRIS_TRINIUM”, “SHIELD”, “IRIS_CREATIVE”]

Returns durability of the iris Returns:

  • formatted : String - Format “<durability>/<maxDurability>”
  • durability : Int - Current durability
  • maxDurability : Int - Maximum durability

Sending data trough open stargate.

Sends IDC code trough outgoing stargate Parameters:

  • code : String - IDC code (String, because it can start with 0)

Returns:

  • success : Boolean - True if no error occurred during processing, otherwise false
  • response : String - [“stargate_not_engaged”, “invalid_target_gate”, “success”],
  • readableResponse : String - Readable response

Sends message to connected gate trough open wormhole Parameters:

  • message : String - Message to send

Returns:

  • success : Boolean - True if no error occurred during processing, otherwise false
  • response : String - [“stargate_failure_not_merged”, “stargate_failure_not_engaged”, “no_listener_available”, “wrong_argument_type”, “success”]
  • readableResponse : String - Readable response

If success is true then:

  • message : String - Sent message

Sends message to player/computer that sent IDC last. This method is intended to be used to reply to stargate_iris_code_received event. Parameters:

  • message : String - Message to send

Returns:

  • success : Boolean - True if no error occurred during processing, otherwise false
  • response : String - [“stargate_failure_not_merged”, “stargate_failure_not_engaged”, “no_listener_available”, “wrong_argument_type”, “success”]
  • readableResponse : String - Readable response

If success is true then:

  • message : String - Sent message

Functions that do only cinematic effects.

Opens chevron’s moving part Parameters:

  • index : Int - Selection of chevron [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] (while 9 is the top chevron)

Returns:

  • success : Boolean - True if no error occurred during processing, otherwise false
  • response : String - [“stargate_not_merged”, “stargate_busy”, “chevron_already_open”, “chevron_open”]
  • readableResponse : String - Readable response

Activates the chevron (lights it up in most cases) Parameters:

  • index : Int - Selection of chevron [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] (while 9 is the top chevron)

Returns:

  • success : Boolean - True if no error occurred during processing, otherwise false
  • response : String - [“stargate_not_merged”, “stargate_busy”, “chevron_already_activated”, “chevron_activate”]
  • readableResponse : String - Readable response

Closes chevron’s moving part Parameters:

  • index : Int - Selection of chevron [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] (while 9 is the top chevron)

Returns:

  • success : Boolean - True if no error occurred during processing, otherwise false
  • response : String - [“stargate_not_merged”, “stargate_busy”, “chevron_already_closed”, “chevron_close”]
  • readableResponse : String - Readable response

Deactivates the chevron Parameters:

  • index : Int - Selection of chevron [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] (while 9 is the top chevron)

Returns:

  • success : Boolean - True if no error occurred during processing, otherwise false
  • response : String - [“stargate_not_merged”, “stargate_busy”, “chevron_already_deactivated”, “chevron_deactivate”]
  • readableResponse : String - Readable response

Fired when gate’s ring starts spinning Parameters:

  • direction : String - Spin direction (“CLOCKWISE” or “COUNTER_CLOCKWISE”)
  • speed : Double - Initial ring speed in deg/tick
script.lua
local eventName, direction, speed = os.pullEvent("stargate_spin_start")

Fired when gate’s ring stops spinning Parameters:

  • topSymbol : ?String - Name of the current symbol under top chevron or nil if between two symbols
script.lua
local eventName, topSymbol = os.pullEvent("stargate_spin_stop")

Fired when chevron is engaged together with symbol Parameters:

  • source : String - Source of this event [“DHD”, “REMOTE”, “BY_SPIN”]
  • symbol : String - Name of the engaged symbol
  • chevron : Int - Engaged chevron’s index [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] (while 9 is the top - final - chevron)
  • dialedAddressSize : Int - New size of dialed address (1~9)
script.lua
local eventName, source, symbol, chevron, dialedAddressSize = os.pullEvent("stargate_chevron_engaged")

Fired when chevron is openned Parameters:

  • chevron : Int - Engaged chevron’s index [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] (while 9 is the top - final - chevron)
script.lua
local eventName, chevron = os.pullEvent("stargate_chevron_open")

Fired when chevron is lit up Parameters:

  • chevron : Int - Engaged chevron’s index [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] (while 9 is the top - final - chevron)
script.lua
local eventName, chevron = os.pullEvent("stargate_chevron_lit")

Fired when chevron is closed Parameters:

  • chevron : Int - Engaged chevron’s index [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] (while 9 is the top - final - chevron)
script.lua
local eventName, chevron = os.pullEvent("stargate_chevron_close")

Outgoing means that this event is fired on outgoing side of the connection.
Incoming means that this event is fired on incoming side of the connection.

Outgoing

Fired when openning the stargate failed Parameters:

  • reason : String - [“NOT_ENOUGH_POWER”, “ADDRESS_MALFORMED”, “ABORTED”, “ABORTED_BY_EVENT”, “CALLER_HUNG_UP”, “GATE_BURRIED”, “TARGET_GATE_BURRIED”]
  • dialedAddress : Table - the dialed address
script.lua
local eventName, reason, dialedAddress = os.pullEvent("stargate_attempt_open_failed")
Outgoing

Fired when closing the stargate failed Parameters:

  • reason : String - [“NOT_OPEN”, “CANNOT_DISENGAGE”, “NOT_INITIATING”, “BLOCKED_BY_EVENT”]
  • dialedAddress : Table - the dialed address
  • isInitiating : Boolean - true if gate has outgoing connection, otherwise false
script.lua
local eventName, reason, dialedAddress, isInitiating = os.pullEvent("stargate_attempt_close_failed")
Incoming

Fired when incoming wormhole occurs Parameters:

  • addressSize : Int - dialed address size (number of lit up chevrons)
script.lua
local eventName, addressSize = os.pullEvent("stargate_wormhole_incoming")
Outgoing Incoming

Fired when subspace connection is made between two gates. No wormhole is present at this point - gates only know about each other. Parameters:

  • dialedAddress : Table - dialed address if fire on outgoing gate, otherwise empty address
  • isInitiating : Boolean - true if it’s fired on outgoing gate
script.lua
local eventName, dialedAddress, isInitiating = os.pullEvent("stargate_wormhole_subspace_connected")
Outgoing Incoming

Fired when wormhole connection is being established. Kawoosh is usually present at this point on both gates. Parameters:

  • dialedAddress : Table - dialed address if fire on outgoing gate, otherwise empty address
  • isInitiating : Boolean - true if it’s fired on outgoing gate
script.lua
local eventName, dialedAddress, isInitiating = os.pullEvent("stargate_wormhole_open_unstable")
Outgoing Incoming

Fired when wormhole connection is fully established. Stable event horizon is present on both gates. Parameters:

  • dialedAddress : Table - dialed address if fire on outgoing gate, otherwise empty address
  • isInitiating : Boolean - true if it’s fired on outgoing gate
script.lua
local eventName, dialedAddress, isInitiating = os.pullEvent("stargate_wormhole_open_fully")
Outgoing Incoming

Fired when wormhole connection is being terminated. The gate’s EH starts flickering on both sides. Parameters:

  • dialedAddress : Table - dialed address if fire on outgoing gate, otherwise empty address
  • reason : String - reason of why is this happening [“REQUESTED”, “CONNECTION_LOST”, “AUTOCLOSE”, “TIME_LIMIT”, “OUT_OF_POWER”, “COMMAND”]
  • isInitiating : Boolean - true if it’s fired on outgoing gate
script.lua
local eventName, dialedAddress, reason, isInitiating = os.pullEvent("stargate_wormhole_close_unstable")
Outgoing Incoming

Fired when wormhole connection is fully terminated. The gates should be idle at this point on both sides. Parameters:

  • dialedAddress : Table - dialed address if fire on outgoing gate, otherwise empty address
  • reason : String - reason of why is this happening [“REQUESTED”, “CONNECTION_LOST”, “AUTOCLOSE”, “TIME_LIMIT”, “OUT_OF_POWER”, “COMMAND”]
  • isInitiating : Boolean - true if it’s fired on outgoing gate
script.lua
local eventName, dialedAddress, reason, isInitiating = os.pullEvent("stargate_wormhole_close_fully")

Fired when event horizon becomes unstable (for example because of power issues) Parameters:

  • isInitiating : Boolean - true if gate has outgoing connection, otherwise false
script.lua
local eventName, isInitiating = os.pullEvent("stargate_event_horizon_unstable")

stargate_event_horizon_unstable_black_hole

Section titled “stargate_event_horizon_unstable_black_hole”

Fired when event horizon becomes unstable by gravitation force of a connected blackhole Parameters:

  • isInitiating : Boolean - true if gate has outgoing connection, otherwise false
script.lua
local eventName, isInitiating = os.pullEvent("stargate_event_horizon_unstable_black_hole")

Fired when event horizon becomes stable again Parameters:

  • isInitiating : Boolean - true if gate has outgoing connection, otherwise false
script.lua
local eventName, isInitiating = os.pullEvent("stargate_event_horizon_stabilized")

Fired when traveler goes trough the gate Parameters:

  • inbound : Boolean - true if it’s and inbound traveler
  • entityType : String - entity type of that traveler

If entityType is instance of Player:

  • playerUUID : String - UUID of the player
  • playerName : String - Nickname of the player
script.lua
local eventName, inbound, entityType, playerUUID, playerName = os.pullEvent("stargate_event_horizon_traveler")

Fired when iris/shield is toggled Parameters:

  • close : Boolean - true when iris is now closing, otherwise false
script.lua
local eventName, close = os.pullEvent("stargate_iris_toggled")

Fired when iris is destroyed Parameters:

  • reason : String - reason why it gets destroyed [“COLLAPSED_UNDER_HIT”, “MELTED_DOWN”]
script.lua
local eventName, reason = os.pullEvent("stargate_iris_destroyed")

Fired when stargate receives IDC code from GDO/Computer on the other side Parameters:

  • code : String - the received code
script.lua
local eventName, code = os.pullEvent("stargate_iris_code_received")

Fired when iris/shield changes its state (closes, opens etc.) Parameters:

  • oldState : String - the old iris state [“OPENED”, “CLOSED”, “OPENING”, “CLOSING”, “ERROR”]
  • newState : String - the new iris state [“OPENED”, “CLOSED”, “OPENING”, “CLOSING”, “ERROR”]
script.lua
local eventName, oldState, newState = os.pullEvent("stargate_iris_state_changed")

Fired when iris/shield changes its type (null, shield, trinium etc.) Parameters:

  • oldType : String - the old iris type [“NULL”, “IRIS_TITANIUM”, “IRIS_TRINIUM”, “SHIELD”, “IRIS_CREATIVE”]
  • newType : String - the new iris type [“NULL”, “IRIS_TITANIUM”, “IRIS_TRINIUM”, “SHIELD”, “IRIS_CREATIVE”]
script.lua
local eventName, oldType, newType = os.pullEvent("stargate_iris_type_changed")

Fired when iris/shield mode changed Parameters:

  • oldMode : String - the old iris mode [“OPENED”, “CLOSED”, “AUTO”, “OC”, “DIALER”]
  • newMode : String - the new iris mode [“OPENED”, “CLOSED”, “AUTO”, “OC”, “DIALER”]
script.lua
local eventName, oldMode, newMode = os.pullEvent("stargate_iris_mode_changed")

Fired when iris is damaged Parameters:

  • source : String - source of that damage [“HIT”, “HEAT”]
  • damage : Int - amount of that damage
script.lua
local eventName, source, damage = os.pullEvent("stargate_iris_damaged")
Fired when iris is hit by an object
script.lua
local eventName = os.pullEvent("stargate_iris_hit")

Fired when stargate receives incoming message trough the open wormhole Parameters:

  • message : String - the message
script.lua
local eventName, message = os.pullEvent("stargate_wormhole_incoming_message")

Fired every 5 seconds (or 100 ticks) This event is fired periodically when gate’s base block is connected to the computer.

script.lua
local eventName = os.pullEvent("stargate_ping")