aboutsummaryrefslogtreecommitdiff
path: root/building_guide/doors.md
blob: 358001f522e2b7f73b1eb4482d7c6beefae8ea1d (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
## Global vs Player State: Door Examples

> **Filenames are IDs.** Object and room YAML below carry no `id:` field — the filename is the ID (e.g. `door_button.yaml` → `door_button`). A nested `- id:` under a room's `objects:` list is a *reference* and stays.

### 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
name: stone button
hidden: true
use_interactions:
  - condition:
      flag: secret_door_open
      not: true
    message: "You press the stone button. You hear grinding stone in the distance."
    action:
      set_global_flags:
        secret_door_open: true
```

**Room 3** — contains the button:
```yaml
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
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
name: rusty key
description: "An old iron key, still functional."
value: 0
stackable: false
```

**Room 5** — locked door:
```yaml
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
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 `global_flag` (shared state — one player presses, everyone benefits), the key door uses `has_item` (per-player inventory check — each player needs their own key).

---