7.3 KiB
7.3 KiB
Item Types
This is behavior-focused documentation for item types and their defaults.
Shared Item Behavior
- Items are server-authoritative.
- Global per-type fields are injected by the server and are not persisted per-instance:
capabilitiesuseSoundemitSounduseCooldownMs(from item catalog)emitRange(spatial range in squares)directional(directional attenuation enabled)
- Instance fields are persisted in
server/runtime/items.json. - Read-only inspect fields include
createdByandupdatedByfor ownership/change tracking.
radio_station
Defaults
- Title:
radio - Params:
streamUrl=""enabled=truemediaChannel="stereo"mediaVolume=50mediaEffect="off"mediaEffectValue=50stationName=""(server-managed, read-only)nowPlaying=""(server-managed, read-only)facing=0emitRange=10
- Global:
useSound=noneemitSound=noneuseCooldownMs=1000emitRange=10directional=true
Use
usetogglesenabledon/off and broadcasts chat status.secondary usereports now-playing metadata (Playing <song> from <station>), or<title> is offwhen disabled.
Validation
mediaChannel:stereo | mono | left | rightmediaVolume: integer0..100mediaEffect:reverb | echo | flanger | high_pass | low_pass | offmediaEffectValue: number0..100with0.1precision- Visible only when
mediaEffect != off(visibleWhen: {"mediaEffect": "!off"})
- Visible only when
facing: number0..360with step1emitRange: integer5..20stationName/nowPlaying: server-fetched metadata fields; not editable by clients.
dice
Defaults
- Title:
Dice - Params:
sides=6number=2
- Global:
useSound=sounds/roll.oggemitSound=noneuseCooldownMs=1000emitRange=15directional=false
Use
- Rolls
numberdice withsidessides and reports values + total.
Validation
sides: integer1..100number: integer1..100
wheel
Defaults
- Title:
wheel - Params:
spaces="yes, no"
- Global:
useSound=sounds/spin.oggemitSound=noneuseCooldownMs=4000emitRange=15directional=false
Use
- Announces spin immediately.
- Result is sent after delay.
Validation
spaces: comma-delimited values- At least 1 entry
- Max 100 entries
- Max 80 chars per entry
clock
Defaults
- Title:
clock - Params:
timeZone="America/Detroit"use24Hour=falsetopOfHourAnnounce=truealarmEnabled=falsealarmTime="12:00 AM"
- Global:
useSound=noneemitSound=sounds/clock.ogguseCooldownMs=1000emitRange=10directional=false
Use
- Broadcasts a spoken EL640-style time announcement as spatial audio from the clock position.
- No text chat line is emitted for clock
use.
Validation
timeZone: one ofCLOCK_TIME_ZONE_OPTIONSinserver/app/item_catalog.pyuse24Hour: boolean or on/off style inputtopOfHourAnnounce: boolean or on/off style inputalarmEnabled: boolean or on/off style inputalarmTime:HH:MMwhenuse24Hour=true, otherwiseH:MM AM/PM- Visible only when
alarmEnabled=true(visibleWhen: {"alarmEnabled": true})
- Visible only when
Audio
- Spoken clock assets live under
client/public/sounds/clock/el640/. - Top-of-hour routine (when enabled) uses
hour1.ogg+ time phrase +hour2.ogg. - Alarm routine (when enabled and time matches) uses
announcement.ogg+ time phrase +alarm.ogg.
widget
Defaults
- Title:
widget - Params:
enabled=truedirectional=falsefacing=0emitRange=15emitVolume=100emitSoundSpeed=50emitSoundTempo=50emitLoopDelay=0emitEffect="off"emitEffectValue=50useSound=""emitSound=""
- Global:
useSound=noneemitSound=noneuseCooldownMs=1000emitRange=15directional=falseemitSoundSpeed=50emitSoundTempo=50emitLoopDelay=0
Use
usetogglesenabledon/off and playsuseSoundwhen configured.
Validation
enabled: boolean or on/off style inputdirectional: boolean or on/off style inputfacing: number0..360with step1emitRange: integer1..20emitVolume: integer0..100emitSoundSpeed: integer0..100(0=0.5x,50=1.0x,100=2.0x) for speed/pitchemitSoundTempo: integer0..100(0=0.5x,50=1.0x,100=2.0x) for tempoemitLoopDelay: number0..300with0.1step/precision; delay in seconds between each emitted loop playbackemitEffect:reverb | echo | flanger | high_pass | low_pass | offemitEffectValue: number0..100with0.1precisionuseSound: empty, filename (assumed undersounds/), or full URLemitSound: empty, filename (assumed undersounds/), or full URL
piano
Defaults
- Title:
piano - Params:
instrument="piano"voiceMode="poly"octave=0attack=15decay=45release=35brightness=55emitRange=15
- Global:
useSound=noneemitSound=noneuseCooldownMs=1000emitRange=15directional=false
Use
- Announces that the user begins playing the piano (client enters piano key mode).
- Piano mode controls include
,to start/stop recording (max 30s) and.to play saved recording. - Recordings are stored on the item (server-authoritative), so nearby users hear playback.
Validation
instrument:piano | electric_piano | guitar | organ | bass | violin | synth_lead | brass | nintendo | drum_kitvoiceMode:poly | monooctave: integer-2..2attack: integer0..100decay: integer0..100release: integer0..100brightness: integer0..100emitRange: integer5..20- Instrument changes reset
voiceMode/octave/attack/decay/release/brightnessto instrument defaults.
Adding A New Item Type (Plugin Discovery)
Server is the source of truth for item type definitions and metadata. The client consumes server welcome.uiDefinitions and only provides UX/runtime behavior.
For a full copy/paste example with plain-English explanation, see docs/item-type-template.md.
- Server item package: add a new folder under
server/app/items/types/<item_type>/with:definition.py(defaults/capabilities/metadata/options)validator.py(validate_update)actions.py(use_item)
- Server plugin: add
server/app/items/types/<item_type>/plugin.pyexportingITEM_TYPE_PLUGINwith:typeordermoduleThe server auto-discovers plugins at boot, so no central registry edit is needed.
- Server/client protocol/state models are now string-based for item type ids; for generic types no enum/union list updates are required.
- Client runtime behavior: add
client/src/items/types/<item_type>/behavior.tsonly if custom client runtime is needed (for example piano mode). - Tests: add or update server tests under
server/tests/for use/update validation, unknown-key stripping, anduiDefinitionscompleteness.
Example Shape
A minimal new item type usually needs:
- Catalog defaults:
default_titledefault_paramsuse_sound/emit_sounduse_cooldown_ms
- Handler behavior:
- validate params on update
- build self/others use messages
- optionally return delayed result text