Connectors and signals
Connectors let one placed Gizmo control another through declared outputs and inputs. A pressure pad can toggle a lamp, a switch can hold several lights on, or a game can signal that a round has ended. Each Gizmo exposes its own capabilities; it never imports or calls another Gizmo's definition.
Port IDs route signals. Labels describe them to players. Two ports are compatible when their kind matches:
| Kind | Meaning | Output value | Example |
|---|---|---|---|
event | A single occurrence | null when it happens; omit otherwise | Someone steps on → Toggle |
boolean | A current on/off value | true or false on every read | While occupied → Power |
Use the existing Pressure pad and Lamp as complete examples. Exact types are in the connections reference.
Connect placed items
- Place a Pressure pad and Lamp that you can edit on the same floor.
- Open the lamp and choose Connect to…. The open lamp is the fixed receiver. Select the bold words to choose its controller, condition and action: “When someone steps on 🔘 Pressure pad, toggle this lamp.”
- Choose Connect, then walk onto the pad. Each accepted arrival toggles the lamp once.
Opening the pad instead fixes that pad as the controller and lets you choose the receiving item. A Gizmo with inputs uses the receiver view even if it also has outputs. To connect one lamp's power to another lamp, open the receiving lamp and choose the other lamp as its controller.
Saved connections appear as single-choice radio rows, such as “Someone steps on 🔘, Toggle 🏮”. Select one to load its settings, then choose Disconnect to remove it. Changing a word edits the draft; Connect saves it. Connect is disabled when the selected connection already exists.
One output can control several receiving items. The same output cannot connect to multiple inputs on the same item: disconnect its existing connection before choosing another action. Different outputs may control the same item—for example, Someone steps on → Turn on and Someone steps off → Turn off.
Expose receiving actions
Adding a switch to a view does not expose a connector automatically. Declare an input that names an existing participant action. The action still validates its payload and returns valid state.
This complete definition exposes event inputs for Toggle and Turn on, a held Power input, and a boolean Power output:
ts
import { defineObject, exactKeys, record, requirePayload, ObjectActionError } from '@scape-wtf/sdk';
type State = { on: boolean };
export const relay = defineObject<State>({
type: 'my-project.relay', version: 1, emoji: '💡',
label: 'Relay', hint: 'switch this relay or connect a controller',
initial: () => ({ on: false }),
valid: (state): state is State =>
record(state) && exactKeys(state, ['on']) && typeof state.on === 'boolean',
actions: {
toggle: {
permission: 'participant',
run: (state, payload) => {
requirePayload(payload, []);
return { on: !state.on };
},
},
power: {
permission: 'participant',
run: (_state, payload) => {
requirePayload(payload, ['on']);
if (typeof payload.on !== 'boolean') throw new ObjectActionError(400, 'Choose on or off.');
return { on: payload.on };
},
},
},
inputs: {
toggle: { label: 'Toggle', phrase: 'toggle', kind: 'event', action: 'toggle' },
on: { label: 'Turn on', phrase: 'turn on', kind: 'event', action: 'power', payload: { on: true } },
power: {
label: 'Power', kind: 'boolean', action: 'power', value: 'on',
combine: 'any', locks: ['toggle', 'power'],
},
},
outputs: { power: { label: 'Power', kind: 'boolean' } },
signals: state => ({ power: state.on }),
view: state => ({
title: 'Relay', description: '',
controls: [{ id: 'toggle', label: state.on ? 'Turn off' : 'Turn on',
icon: 'toggle', pressed: state.on, action: { name: 'toggle', payload: {} } }],
}),
});1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
For an event input, optional payload supplies fixed action arguments. For a boolean input, value names the payload field that receives the boolean; it overrides that field in any fixed payload. Here Power invokes power with { on: true } or { on: false }.
Only participant actions can be inputs. Signals cannot invoke editor/remover actions, and definitions with navigation, world editing or area removal cannot expose inputs. Signal delivery uses a Scape actor with no editing or removal authority; do not interpret it as the player who stepped on a pad or pressed a switch.
Emit your own signals
signals(state, previous, action) is a pure callback. Scape calls it after accepted actions and reads it with action: null for initial binding and current boolean values. Report every authored boolean output on every call. Include an event output with null only when an action should emit it; omit that output at other times. Never emit events on a null-action read.
For example, this capability can be spread into a game definition whose state contains finished:
ts
import type { ObjectAction, GizmoOutput, GizmoSignals } from '@scape-wtf/sdk';
type RoundState = { finished: boolean };
export const roundSignals = {
outputs: {
ended: { label: 'Round ended', phrase: 'a round ends on', kind: 'event' },
finished: { label: 'Finished', kind: 'boolean' },
} satisfies Record<string, GizmoOutput>,
signals(state: RoundState, previous: RoundState, action: ObjectAction | null): GizmoSignals {
return {
finished: state.finished,
...(action && !previous.finished && state.finished ? { ended: null } : {}),
};
},
};1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
An event carries no arbitrary message payload. The receiving input chooses its fixed action arguments. Boolean outputs describe a current value, not a request to toggle each time Scape reads them.
Use movement signals
A walkable definition can expose movement outputs supplied by Scape without a signals callback. Spread these capabilities into your definition:
ts
import type { ObjectDefinition } from '@scape-wtf/sdk';
export const movementSignals = {
walkable: true,
outputs: {
pressed: { label: 'Someone steps on', kind: 'event', source: 'arrival' },
released: { label: 'Someone steps off', kind: 'event', source: 'departure' },
occupied: { label: 'While occupied', kind: 'boolean', source: 'occupancy' },
},
} satisfies Pick<ObjectDefinition, 'walkable' | 'outputs'>;1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
arrival and departure are events; occupancy is a boolean. All require walkable: true. Authored signals must not return values for outputs with a source.
Accepted walking and pushed arrivals generate movement events. Joining, reconnecting and teleporting do not generate arrival/departure pulses. Occupancy still reflects whether connected players occupy that item on its floor, including after departure or reconnection. The cosmetic step() callback remains separate and cannot mutate shared state.
Hold a value while connected
Boolean inputs accept one connection unless they declare combine: 'any'. With any, the input is true while at least one connected output is true. This lets several pressure pads hold one lamp on.
Scape applies the combined value when it changes, including initial binding. Removing the final connection sets the input to false. Use a setter action such as power, rather than a toggle, so repeated reads do not invert state.
locks lists manual actions disabled while the boolean input is connected, even while its value is false. It defaults to the input's own action. A lamp should lock both power and toggle while a pad holds its Power input. Conflicting event connections to those locked actions are rejected. After disconnection, manual controls become available again. Event inputs do not lock manual controls.
Write readable labels
Every port needs a short label. Event ports can also provide an optional phrase for the sentence editor:
- An output phrase goes before its source:
a round ends onGame. - An input phrase goes before its receiver:
turn onLamp.
Together they read “When a round ends on Game, turn on this lamp.” Without phrases, Scape uses explicit wording such as “When Round ended is triggered on Game, run Toggle on this lamp.” Movement outputs have standard wording. Boolean ports use their labels in “Match Power on this lamp to occupancy on Pressure pad” and do not accept phrase.
Phrases only change presentation. They never change routing, permissions or action arguments. Keep port IDs stable when editing labels.
Ownership, persistence and limits
Connections require edit access to both items, the same owner and the same floor. Scape owns ObjectInstance.connections and signalInputs; keep them out of authored state and portable configuration. Moving an item on its floor preserves its connections; deleting an endpoint removes affected connections. Unknown definitions leave saved connections inert until a compatible definition is available. Updates must preserve valid connected ports, kinds and actions; disconnect affected wires before making an incompatible change.
Scape rejects cycles, incompatible kinds and duplicate output-to-receiver connections. There is no fixed count cap on outgoing connections per placed item, connections per world or action deliveries per propagation. A pad can directly control a whole group of lamps without relay lamps. Definitions support eight inputs and eight outputs, chains allow up to 16 links, and each propagation has a 250 ms execution budget. Existing world and request size limits still apply. If propagation fails, its state changes and feedback roll back. See all connector limits.
Test and troubleshoot
Use ObjectRegistry from @scape-wtf/sdk/runtime to test your definition and inspect registry.execute(instance, action, context).signals. Test boolean values on initial reads, event emission only on intended actions, and payload rejection in each receiving action. Test with the existing pad and lamp in your developer world to check actual wiring, permissions, movement and multiple connected items; local reducer tests do not simulate world delivery.
If a choice is missing, check matching kinds, editing rights, owner/floor, existing held-input locks and connection limits. A manual control disabled by a held input becomes available after disconnecting it. If an update is rejected, keep the last accepted project active and restore the connected port contract or disconnect those wires before trying again.
