Walkable tile
A walkable floor tile with an emoji appearance chosen by the world owner or moderators.
What it demonstrates: A native curated emoji picker, owner/moderator configuration and walkability without effects.
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/walkable-tile
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
Open Configure and search or browse the game emoji library. Choosing an emoji changes the picture while preserving walkability. Reuse the emoji field in another gizmo; the host supplies the picker and its choices.
Source
This code is included directly from the working example when the site builds.
src/definition.ts
ts
/** A configurable floor tile. Scape supplies rendering, movement and editing authority. */
import {
defineObject,
exactKeys,
ObjectActionError,
record,
requirePayload,
validObjectFieldValue,
} from '@scape-wtf/sdk';
/** Appearance belongs to each placed tile, independently of its catalog identity. */
export interface WalkableTileState {
/** Optional for older canonical tiles; blue identities require the operator migration. */
emoji?: string;
}
// The SDK checks emoji syntax; Scape additionally restricts picker submissions
// to its current game library, without coupling this project to a host catalog.
const validEmoji = (value: unknown): value is string =>
validObjectFieldValue({ id: 'emoji', label: 'Appearance', kind: 'emoji', value: '🔳' }, value);
export const walkableTile = defineObject<WalkableTileState>({
type: 'example.walkable-tile',
version: 1,
emoji: '🔳',
label: 'Walkable tile',
hint: 'a walkable floor tile with an emoji chosen by the world owner or moderators',
initial: () => ({ emoji: '🔳' }),
valid: (state): state is WalkableTileState =>
record(state) &&
exactKeys(state, ['emoji']) &&
(!Object.prototype.hasOwnProperty.call(state, 'emoji') || validEmoji(state.emoji)),
walkable: true,
editPolicy: 'placer-admin',
configuration: { action: 'appearance', fields: ['emoji'], remember: true },
actions: {
appearance: {
permission: 'editor',
run: (_state, payload) => {
requirePayload(payload, ['emoji']);
const emoji = typeof payload.emoji === 'string' ? payload.emoji.trim() : '';
if (!validEmoji(emoji)) throw new ObjectActionError(400, 'Choose one emoji.');
return { emoji };
},
},
},
view: (state, viewer) => ({
title: 'Walkable tile',
description: '',
fields: viewer.canEdit
? [{ id: 'emoji', label: 'Appearance', kind: 'emoji', value: state.emoji ?? '🔳' }]
: [],
controls: viewer.canEdit
? [
{
id: 'appearance',
label: 'Set appearance',
fields: ['emoji'],
trigger: 'change',
action: { name: 'appearance', payload: {} },
},
]
: [],
}),
// A full-cell emoji uses the existing bounded text-sprite capability. It does
// not acquire the behavior of the chosen emoji (for example, fire or a portal).
sprite: state => ({
size: 64,
layers: [
{
id: 'tile',
shapes: [
{
kind: 'text',
x: 32,
y: 32,
text: state.emoji ?? '🔳',
size: 56,
weight: 400,
color: '#ffffff',
},
],
},
],
}),
});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
86
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
86
src/project.ts
ts
/** Project entry: exports walkable-tile to Scape's SDK loader. */
import { defineProject } from '@scape-wtf/sdk';
import { walkableTile } from './definition.js';
export default defineProject({
name: 'Walkable tile',
description:
'Place a walkable floor tile and let world owners or moderators choose its emoji appearance.',
objects: [walkableTile],
});1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
