Chime
Bumping the Chime immediately plays a sound and blue burst, then shares accepted feedback with nearby players.
What it demonstrates: Bump actions · immediate contact feedback · sound and burst replacement · shared reactions.
Run this example
All learning examples are available in your developer world on scape.wtf. To edit this example, clone the public Scape tools repository and run its project with Node.js 22+:
sh
git clone https://github.com/scape-wtf/scape-tools.git
cd scape-tools
npm install
cd examples/gizmos/chime
npm run build
npm test
npm exec -- scape gizmo dev1
2
3
4
5
6
7
2
3
4
5
6
7
This connects to https://scape.wtf. Follow connection and approval. To make an independent project, copy this example directory outside the checkout, then run npm install, npm run build, npm test and npm exec -- scape gizmo dev there. Its manifest uses published SDK and CLI dependencies. The project's npm run dev script is a shortcut for scape gizmo dev.
Try changing it
Try audioMode or burstMode set to overlap, then compare repeated bumps with replace. Keep the same contact recipe in interactionFeedback and react so confirmations do not replay it. See contact feedback and testing under delay.
Source
This code is included directly from the working example when the site builds.
src/definition.ts
ts
/** Chime owns the bump action and ring recipe; Scape supplies shared delivery and output. */
import {
defineObject,
record,
requirePayload,
type GizmoInteractionFeedback,
} from '@scape-wtf/sdk';
const ringFeedback: GizmoInteractionFeedback = {
durationMs: 600,
audioMode: 'replace',
burstMode: 'replace',
burst: {
color: '#a9e8ff',
radiusCells: 1.5,
particles: 0,
},
audio: [
{
kind: 'play',
voice: 'ring',
delayMs: 0,
sound: 'ring',
gain: 1,
rate: 1,
loop: false,
rangeCells: [1, 8],
stereo: 0.7,
},
],
};
/** Chime supplies a signal recipe; Scape supplies shared delivery and output. */
export const chime = defineObject<{ lastAt: number }>({
type: 'examples.chime',
version: 1,
emoji: '🛎️',
label: 'Chime',
hint: 'Bump to ring for nearby players',
interaction: { bump: { name: 'ring', payload: {} } },
interactionFeedback: { ring: ringFeedback },
initial: () => ({ lastAt: 0 }),
valid: (state): state is { lastAt: number } =>
record(state) &&
Object.keys(state).length === 1 &&
Number.isSafeInteger(state.lastAt) &&
Number(state.lastAt) >= 0,
actions: {
ring: {
permission: 'participant',
run: (_state, payload, context) => {
requirePayload(payload, []);
return { lastAt: context.now };
},
},
},
sounds: {
ring: {
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 },
],
},
],
},
},
// Saved timestamps retain compatibility. Other players hear the accepted ring.
react: () => ({
feedback: {
...ringFeedback,
},
}),
});
export default chime;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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
src/project.ts
ts
/** Project entry: exports chime to Scape's SDK loader. */
import { defineProject } from '@scape-wtf/sdk';
import { chime } from './definition.js';
export default defineProject({
name: 'Chime',
description: 'Bump to ring instantly; each hit restarts the chime for nearby players.',
objects: [chime],
});1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
