Chime
An accepted action produces a brief shared sound through the normal action row.
What it demonstrates: Primary action · shared reactions · procedural audio.
Run this example
All learning examples appear in a compatible developer world. To export a standalone project, an operator with source access runs this from the Scape repository (choose a new destination under an existing directory):
sh
yarn sdk:starter /path/to/my-chime --template chime1
In the exported project:
sh
yarn install
yarn build
yarn dev --origin https://your-scape-host1
2
3
2
3
Follow connection and approval. The exported dev script invokes scape gizmo dev. The kit includes three private archives for the SDK, CLI and MCP server; keep them and the Yarn resolutions together. Third-party dependencies still need installation. See the CLI reference for commands; no public Scape registry install is available yet.
Try changing it
Change the sound recipe or feedback. Use a local preview when only the author should hear it.
Source
This code is included directly from the working example when the site builds.
src/definition.ts
ts
/** Chime owns the ring recipe and cooldown; Scape supplies shared delivery and output. */
import { defineObject, record, requirePayload, ObjectActionError } from '@scape/sdk';
/** 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: 'Ring for nearby players',
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, []);
if (context.now - state.lastAt < 250)
throw new ObjectActionError(409, 'Let the chime ring');
return { lastAt: context.now };
},
},
},
view: () => ({
title: 'Chime',
description: '',
controls: [
{
id: 'ring',
label: 'Ring',
placement: 'action',
action: { name: 'ring', payload: {} },
},
],
}),
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 enforce timing; only this accepted-action result causes playback.
react: () => ({
feedback: {
durationMs: 600,
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,
},
],
},
}),
});
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
85
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
85
src/project.ts
ts
/** Project entry: exports chime to Scape's SDK loader. */
import { defineProject } from '@scape/sdk';
import { chime } from './definition.js';
export default defineProject({ objects: [chime] });1
2
3
4
5
2
3
4
5
