Skip to main content

TriggerRelay

Acts as a TriggerWrite when active/green, but when black or inactive it acts as a normal object, it will not toggle when exposed to Polysilicon signals, rather, it will pass them through if it is active, as if it were a normal signal. It is a craftable and spawnable non-flammable solid.

Here is a list of possible sizes that reach the maximum malleability (144) that have integer components: 1x1x144, 1x2x72, 1x3x48, 1x4x36, 1x6x24, 1x8x18, 1x9x16, 1x12x12, 2x2x36, 2x3x24, 2x4x18, 2x6x12, 2x8x9, 3x3x16, 3x4x12, 3x6x8, 4x4x9, 4x6x6

At its default size (2x1x2) it has a durability of 3, at its maximum size it has a durability of 10.

By default, its colour is #111111.

It requires 1 Copper and 1 Silicon to be crafted.

Configurables


SwitchValue

Determines whether the switch is active or not. It is a boolean.

local sift = require("sift") -- Grab this fancy library for manipulating tables provided by wos.

-- Get all of the types of objects with a `SwitchValue` (save for `TemperatureGate`) configurable
-- and merge them into one big table.
local objects = sift.Array.merge(
GetParts("Switch"),
GetParts("TriggerSwitch"),
GetParts("Valve"),
GetParts("Hatch"),
GetParts("HeatValve")
)

-- Have a 50/50 chance to be on/off when the code starts running.
local initialState = math.random() > 0.5

-- Iterate over all of the switch objects and disable them. `_` is used as a placeholder variable.
for _, switch in objects do
-- You could alternatively do `switch:Configure({ SwitchValue = initialState })`
switch.SwitchValue = initialState
end

-- Connect to the `Loop` event of the `Microcontroller` that is running the code,
-- this will make the code within run precisely every game tick.
Microcontroller.Loop:Connect(function()
-- Iterate over all the switches again!
for _, switch in objects do
-- Here we *read* the `SwitchValue`, then invert it, then write it back, as
-- to toggle the switch.
switch.SwitchValue = not switch.SwitchValue
end
end)

Events


Configured(configurerId)

Fires when the object is configured.

The configurerId parameter is the UserId of the player who configured the object. It is a number.


OnClick(clickerId)

Fires when the object is clicked.

The clickerId parameter is the UserId of the player who clicked the object. It is a number.