Object
"Everything is an object. Objects have slots. Slots hold data OR behavior."
— Dave Ungar, Self: The Power of Simplicity
What Is It?
An Object is anything you can interact with in the adventure world. Keys, lamps, chests, furniture, food, tools — all objects.
Objects are the atoms of the adventure. They:
- Have an identity (id, name, description)
- Advertise their actions (The Sims style)
- Contain state (lit, fuel, uses)
- Inherit from prototypes (Self style)
The Sims Architecture
From Will Wright's SimAntics:
"The intelligence is in the objects, not the characters."
Objects advertise what they can do:
advertisements:
LIGHT:
description: "Light the lamp"
score: 80
guard: "lamp has fuel"
effect: "Darkness retreats"
The character picks from what's advertised. No hardcoded behavior.
Self-Style Prototypes
An object that is a variant of another says so and states only what differs:
# examples/oil-lamp.yml
name: "Oil Lamp"
inherits: [brass-lantern.yml] # simulate, methods and advertisements come from there
state:
lit: false
fuel: 60
A lookup reads the object, then each inherits: parent depth-first, then the defaults.object
of enclosing CONTAINER.yml files, then the prototype object. A map the object states replaces
the inherited map whole, so an object with its own advertisements: gets none of its parent's.