blob: afe4556f7a33f19699c276140388d69addc8216f (
plain)
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
## Global vs Player State: Door Examples
### Example A: Door with a button in another room (GLOBAL)
A button in room 3 opens a door in room 7. Anyone can press it. Once pressed, the door is open for everyone.
**Button object** (`data/objects/door_button.yaml`):
```yaml
id: door_button
name: stone button
behavior: button_toggle
hidden: true
```
**Button behavior** (`data/behaviors/button_toggle.yaml`):
```yaml
id: button_toggle
type: toggle
message: "You press the stone button. You hear grinding stone in the distance."
set_flags:
secret_door_open: true # WORLD flag
check:
flag: secret_door_open
not: true # only works when door is closed
```
**Room 3** — contains the button:
```yaml
id: 3
name: "Button Chamber"
description: "A small stone chamber. A button protrudes from the east wall."
exits:
south: 1
objects:
- id: door_button
```
**Room 7** — contains the door:
```yaml
id: 7
name: "Hidden Passage"
description: "A dusty corridor. A heavy stone door blocks the way north."
exits:
south: 2
north:
room: 8
condition:
flag: secret_door_open # checks WORLD flag
value: true
blocked_message: "A heavy stone door blocks the way."
objects:
- id: stone_door
hidden: true
```
### Example B: Key-locked door (PLAYER-LOCAL)
A locked door that only opens for a player carrying the key. Each player must find their own key.
**Key item** (`data/items/rusty_key.yaml`):
```yaml
id: rusty_key
name: rusty key
description: "An old iron key, still functional."
value: 0
stackable: false
```
**Room 5** — locked door:
```yaml
id: 5
name: "Locked Storage"
description: "A small storage room. The way east is blocked by a locked iron door."
exits:
west: 2
east:
room: 6
condition:
has_item: rusty_key # checks PLAYER inventory
blocked_message: "The iron door is locked. You need a key."
objects:
- id: iron_door
hidden: true
```
**Room 6** — the other side (no key needed to exit):
```yaml
id: 6
name: "Storage Closet"
description: "Shelves of dusty crates."
exits:
west: 5 # exit back — no condition
spawns:
- item_id: uncut_ruby
quantity: 1
respawn_ticks: 500
```
Key difference: the button door uses `flag` (shared state — one player presses, everyone benefits), the key door uses `has_item` (per-player inventory check — each player needs their own key).
---
|