Shared action reactions
Use react when an accepted action should produce a short-lived effect for nearby participants. It runs after the reducer and returns bounded feedback, optional area-removal intent, or null.
Input is separate from reaction
An interaction declares tap or bump actions. The action still passes normal permission and payload checks. react(state, previous, action, context) then describes the outcome.
ts
react: () => ({
feedback: {
durationMs: 600,
burst: { color: '#a9e8ff', radiusCells: 1.5, particles: 0 },
audio: [{ kind: 'play', voice: 'bell', sound: 'bell', delayMs: 0,
gain: 1, rate: 1, loop: false, rangeCells: [1, 8], stereo: 0.7 }],
},
}),1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
Declare the referenced sound in sounds or soundBank. Chime is a complete example.
Immediate contact feedback
Use interactionFeedback when a tap or bump should sound or animate immediately. Scape starts this feedback for the player making contact before the action's response arrives. Keep result-dependent effects in react.
Key the declaration by an action named in interaction. That action must have permission: 'participant'. Reuse the contact recipe in react to share the accepted sound and burst with nearby players:
ts
import { defineObject, requirePayload, type GizmoInteractionFeedback } from '@scape-wtf/sdk';
const contact = {
durationMs: 600,
audioMode: 'replace',
burstMode: 'replace',
burst: { color: '#a9e8ff', radiusCells: 1.5, particles: 0 },
audio: [{
kind: 'play', voice: 'ring', sound: 'bell', delayMs: 0,
gain: 1, rate: 1, loop: false, rangeCells: [1, 8], stereo: 0.7,
}],
} satisfies GizmoInteractionFeedback;
export const contactChime = defineObject<null>({
type: 'my-world.contact-chime',
version: 1,
emoji: '🛎️',
label: 'Contact chime',
hint: 'Bump to ring',
initial: () => null,
valid: (state): state is null => state === null,
interaction: { bump: { name: 'ring', payload: {} } },
interactionFeedback: { ring: contact },
actions: {
ring: {
permission: 'participant',
run: (state, payload) => {
requirePayload(payload, []);
return state;
},
},
},
sounds: {
bell: {
kind: 'synth', duration: 0.6,
voices: [{
wave: 'sine', start: 0, duration: 0.55, frequency: 880,
gain: [{ time: 0, value: 0 }, { time: 0.005, value: 0.2 }, { time: 0.55, value: 0 }],
}],
},
},
react: () => ({ feedback: contact }),
});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
Contact feedback acknowledges an attempt. It can play even when the action is later rejected; it does not predict state, rewards or random results. The declaration is static data and may contain audio, a burst, or both. It cannot contain lighting, haptics, camera shake, sprite impulses or result numbers. All contact audio commands start at delayMs: 0 and playback cannot loop.
Replace or overlap
audioMode: 'replace' replaces matching named voices on the same placed object and floor. burstMode: 'replace' independently restarts that object's burst. Omitting either mode uses overlap for that effect. Other placed objects remain independent. Both modes also apply to accepted feedback returned by react.
The initiating player does not hear the same contact voice or see the same burst again when confirmation arrives. Use a different voice name for a confirmed result sound; a different burst recipe or duration also remains a confirmed result. Other players receive the accepted feedback.
Scape discards contact audio that cannot start within 120 ms. Contact feedback older than one second is omitted from shared delivery, preventing delayed actions from producing catch-up effects; the action and distinct results still complete. Feedback remains best effort. Reduced motion, hidden gameplay, removed objects and floor changes can suppress or end it.
See contact limits and testing repeated contact.
Delivery
Scape validates feedback before committing state, then emits a transient event after the scene transaction succeeds. Scape supplies position, floor, time, instance and operation identity.
Retries, repeated snapshots and late joins do not replay feedback. Delivery is best effort; it is not a durable message queue. Stale events, mismatched builds, floor changes and inactive gameplay cancel or suppress output.
Effects last 1–2,000 ms. Audio must be non-looping and start before expiry. Optional burst, lighting, sprite impulse, camera shake and haptic feedback are bounded. Reduced motion suppresses moving particles, impulses and camera shake.
Custom haptic patterns
Use feedback.haptic for device feedback received only by the player who initiated an accepted action. Choose 'light' or 'heavy' for a preset, or provide a GizmoHapticPattern for a timed sequence. The same recipe works in travel and world-navigation feedback, where only the moving player feels it.
ts
import type { GizmoFeedback, GizmoHapticPattern } from '@scape-wtf/sdk';
const portalPattern: GizmoHapticPattern = {
fallback: 'light',
events: [
{ kind: 'continuous', delayMs: 0, durationMs: 300, intensity: 0.22, sharpness: 0.38 },
{ kind: 'transient', delayMs: 70, intensity: 0.25, sharpness: 0.78 },
{ kind: 'transient', delayMs: 170, intensity: 0.34, sharpness: 0.92 },
{ kind: 'transient', delayMs: 270, intensity: 0.22, sharpness: 0.42 },
],
};
export const portalFeedback: GizmoFeedback = {
durationMs: 320,
haptic: portalPattern,
};1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Return this feedback from react, or use it as the feedback field of a travel or navigation recipe. Portal uses this pattern to combine a 300 ms sustained vibration with three taps. Haptics do not require an audio recipe.
Each pattern contains 1–16 events. All times are milliseconds; intensity and sharpness are finite numbers from 0 to 1. Intensity controls strength, while sharpness controls the feel from rounded to crisp. A transient is a brief tap; a continuous event also requires durationMs of at least 1 ms. Events must start before the enclosing feedback ends, and continuous events must finish within it. Feedback lasts at most 2,000 ms. Invalid recipes are rejected.
Custom patterns play on supported native iOS devices. The optional fallback: 'light' | 'heavy' selects a preset when custom playback is unavailable. Without a fallback, unsupported devices stay silent. Browsers retain preset behavior where supported; they do not reproduce custom intensity or sharpness. Device haptics are best effort and must not be the only indication of success.
A new custom pattern replaces the previous custom pattern. Backgrounding stops playback, and returning does not resume old gestures. A failed custom playback request is not replayed as a fallback. Physical feel needs device testing.
Custom haptics belong to accepted feedback, not interactionFeedback contact previews. See the haptics API, haptic limits, and travel and navigation.
Removal is a separate capability
areaRemoval: { radiusCells } declares a maximum from 0 to 3. A reaction may request removeArea within that maximum. Scape anchors the square at the source on its current floor.
The actor must be allowed to remove the source, and every candidate is checked separately. Entry protection, ownership and world rules still apply. State and permitted removals commit atomically. Authors cannot choose arbitrary coordinates, another floor, or item IDs.
Use permission: 'remover' when invoking the action itself requires source-removal rights. This is the composition used by the built-in Bomb.
Local tests
Use ObjectRegistry.execute to get both the new instance and reaction. act returns only the new instance. Supplying permission in a test fixture simulates authority; it does not authenticate a player.
See reaction declarations and the local test runtime.
