Rooms are little abstractions of environment between which players are moved.
Rooms can contain objects. Objects in a room are accessible as long as the room they are in is current on the current player.
room [INDENTIFIER] [INHERITANCE_CLAUSE]
{
/* Lifecycle */
init() { ... }
/* Events */
onAction(action) { ... }
onActionWith(action, object) { ... }
onActionWithAncestor(action, object) { ... }
onActionWithOther(action) { ... }
onModalAction(action, mode) { ... }
}
[IDENTIFIER] | An internal identifier that represents this room in the rest of TAMEScript. This identifier must not be used to describe another element. |
[INHERITANCE_CLAUSE] | If this room inherits entry points and functions from another room, you declare its parent room by adding a colon (:) plus the identifier of the parent room. |
Command Name | Parameters | Description |
---|---|---|
Init | None | Called at module context initialization on each element. |
OnAction | ACTION | Called when an action needs to be processed on a specific element. Action type decides the element entry point. |
OnActionWith | ACTION, OBJECT | Called when a [di]transitive action needs to be processed with a specific object. |
OnActionWithAncestor | ACTION, OBJECT | Called when a [di]transitive action needs to be processed with a matched ancestor object (if OnActionWith is unhandled). |
OnActionWithOther | ACTION | Called when a [di]transitive action needs to be processed with a valid object, but the object is not handled by OnActionWith or OnActionWithAncestor. |
OnModalAction | ACTION, STRING | Called when a modal action needs to be processed with a specific mode. |
The keyword archetype can be used to create rooms that have common functions and entry points to share among similar rooms. Archetyped rooms can inherit from other parent rooms and archetyped rooms.
Archetyped rooms also cannot be used in commands as through they were real elements. Archetypes also do not hold a context state, nor is their context state saved.
room archetype [INDENTIFIER] [INHERITANCE_CLAUSE]
{
/* Lifecycle */
init() { ... }
/* Events */
onAction(action) { ... }
onActionWith(action, object) { ... }
onActionWithAncestor(action, object) { ... }
onActionWithOther(action) { ... }
onModalAction(action, mode) { ... }
}
TAMEScript's compiler is single-pass: it parses through the module code once, so if the compiler encounters a room identifier that has not been declared yet, it may need to be prototyped.
Prototyping a room is essentially declaring a room, but with a semicolon after its main declaration instead of a declaration body wrapped in curly-braces ({ }). A parent room to inherit from, if any, will need to be declared here.
If you have already declared a room as a prototype (or with a declaration body) and wish to add to it later in code, you'll need to extend it using the extend keyword. When using extend, you cannot change its lineage (parent).
room r_foyer;
extend room r_foyer
{
/* ...stuff goes here... */
}
Rooms don't necessarily have to be "rooms" - a room is an abstraction of a player's current environmental state. A room can represent a "current conversation" with a character in your world, or a close-up of an object that you are examining more closely.
Since a player maintains its current room as a stack rather than a single value, you can easily change this state by preserving a player's previous room (PushRoom()), and jumping back to it when the "sub-state" is left (PopRoom())!