Constructors
These functions are used to create the fundamental objects of your game world.
Booktasy.Room(name, description)
Creates a new Room object.
Parameters
- name (string) — The display name of the room (e.g.,
"Kitchen"). - description (string) — The text shown when looking at the room.
Returns
A Room table containing:
| Field | Type | Description |
|---|---|---|
items | table | List of items on the floor. |
entities | table | List of NPCs/entities in the room. |
exits | table | Dictionary of direction keys → room names. |
describe() | method | Prints the room description, contents, and exits. |
Booktasy.Entity(name, description, opts)
Creates a new Entity (NPC).
Parameters
- name (string) — Identifier (e.g.,
"Guard"). - description (string) — Text shown when looking at the entity.
- opts (table, optional):
- dialogue (table of strings) — Lines spoken when the player uses talk.
- inventory (table) — Items held by the entity.
Methods
- handle_command(verb, target)
Built-in handler for"look"and"talk".
Returnstrueif the command was handled.
Booktasy.Item(name, description, opts)
Creates a new Item.
Parameters
- name (string) — The name referenced in commands (e.g.,
"rusty key"). - description (string) — Text shown when looking at the item.
- opts (table, optional):
- usable (boolean) — True if the item can be used (default
false).
- usable (boolean) — True if the item can be used (default
Booktasy.Event(name, condition_func, action_func, is_one_shot)
Creates a gameplay Event logic block.
Parameters
- name (string) — Unique identifier.
- condition_func (function) — Must return true to trigger.
- action_func (function) — Executed when the event triggers.
- is_one_shot (boolean) — If
true, the event is removed after firing once.