Every module contains one world. The world is the main abstraction of the concept of everything.
The world can also hold objects. Objects owned by the world are always accessible, especially to all players (even if no player is set). While nothing is specifically connected to it, it is a primary context that you can count on existing, and contains entry points that are executed every request, or after the module initializes every element's context. All actions and failure to execute actions fall through to this for handling.
world
{
/* Lifecycle */
init() { ... }
start() { ... }
afterSuccessfulCommand() { ... }
afterFailedCommand() { ... }
afterEveryCommand() { ... }
/* Events */
onAction(action) { ... }
onActionWith(action, object) { ... }
onActionWithAncestor(action, object) { ... }
onActionWithOther(action) { ... }
onModalAction(action, mode) { ... }
onUnhandledAction() { ... }
onUnhandledAction(action) { ... }
onUnknownCommand() { ... }
onMalformedCommand() { ... }
onMalformedCommand(action) { ... }
onIncompleteCommand() { ... }
onIncompleteCommand(action) { ... }
onAmbiguousCommand() { ... }
onAmbiguousCommand(action) { ... }
}
Every TAME module contains one world. It is represented in TAMEScript as a section called "world", which contains a series of blocks that the world needs to handle.
The smallest TAME module (that does something) can be this small:
world
{
start()
{
textln("Hello, world!");
}
}
Command Name | Parameters | Description |
---|---|---|
Init | None | Called at module context initialization on each element. |
Start | None | Called after all elements initialize. |
AfterSuccessfulCommand | None | Called after a processed action due to a correctly-parsed input. |
AfterFailedCommand | None | Called after a processed action due to an incorrectly-parsed input. |
AfterEveryCommand | None | Called after every processed action and after when AfterSuccessfulCommand or AfterFailedCommand is called. |
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. |
OnUnhandledAction | ACTION [optional] | Called when an action is not handled by the elements that should have handled it. |
OnUnknownCommand | None | Called if an action is not interpreted. |
OnMalformedCommand | ACTION [optional] | Called if an interpreted action has a part that isn't found, or if a strict command has more parsed than needed. |
OnIncompleteCommand | ACTION [optional] | Called if an interpreted action is missing a element that is expected, but not parsed. |
OnAmbiguousCommand | ACTION [optional] | Called if an interpreted action can have more than one possible object target based on the input. |
There is only one world element, so it cannot be made into an archetype.
The world is omnipresent and known to the TAMEScript compiler, so you don't need to prototype it in order to "use it later."
However, if you have already declared it and wish to add to it later in code (also not recommended), you'll need to extend it like other elements using the extend keyword.
extend world
{
/* ...stuff goes here... */
}