The basic_object is the common prototype of all in-game objects.
It keeps a reference to the singleton Game object allowing that to be looked
up from any other object.
It handles getting attribute values.
It handles execution of named event handler.
- Source:
Methods
(static) applyEffect(effect_id, slot_id, item_id)
Parameters:
Name | Type | Description |
---|---|---|
effect_id |
string | |
slot_id |
string | |
item_id |
string |
- Source:
(static) copyAssigningId(id) → {object}
creates a copy of this object. If this object has `$template: true` the copy will have `$template: false`. The copy will also be assigned a new attribute `$original_id` containing the id of this object.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | the id to assign to the copy |
- Source:
Returns:
copy of the current object
- Type
- object
(static) copyWithAutoId()
creates a copy of this object that is assigned an ID automatically. In all other respects its behaviour is identical to `copyAssigningId`
Copies an object with an auto-generated ID
- Source:
(static) createDynamicProperties()
creates synthetic properties to represent dynamic attributes types such as `ptable` and `tracery_grammar`.
- Source:
(static) createStaticProperties()
uses basic_object.createStaticProperty to create static properties for all of the objects declared Rez attributes
- Source:
(static) createStaticProperty(attr_name)
use this to create a JS property backed by a Rez attribute
Parameters:
Name | Type | Description |
---|---|---|
attr_name |
string | name of the attribute to create a corresponding property for |
- Source:
(static) elementInitializer()
objects using basic_object as a prototype should define their own elementInitializer function to handle any element-specific initialization
- Source:
(static) eventHandler(event_name) → {function|undefined}
Returns the event handler function stored in attribute "on_" or undefined if no handler is present
Parameters:
Name | Type | Description |
---|---|---|
event_name |
string | name of the event whose handler should be returned |
- Source:
Returns:
event handle function or undefined
- Type
- function | undefined
(static) getAttribute(name) → {*}
returns the value of the attribute with the given name. If no such attribute is present returns `undefined`
Parameters:
Name | Type | Description |
---|---|---|
name |
string | name of the attribute |
- Source:
Returns:
attribute value
- Type
- *
(static) getAttributeValue(name, default_value) → {*}
returns the value of the attribute with the given name. If no such value is present it returns the default value. If no default value is given it throws an exception.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | name of the attribute |
default_value |
* | value to return if no such attribute is present |
- Source:
Returns:
attribute value
- Type
- *
(static) getNextAutoId()
returns the next auto id in the sequence
- Source:
(static) getObjectViaAttribute(name, default_value)
Parameters:
Name | Type | Description |
---|---|---|
name |
string | attribute name |
default_value |
* |
- Source:
(static) hasAttribute(name) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
name |
string | name of the attribute |
- Source:
Returns:
true if the object defines the specified attribute
- Type
- boolean
(static) init(level)
Performs the specified level of initialization on this game object.
This is called automatically by the framework when the game is starting.
Parameters:
Name | Type | Description |
---|---|---|
level |
number | the initialization level (0+) to perform |
- Source:
(static) init_0()
Initialize all static and dynamic properties
- Source:
(static) init_1()
Initialize all dynamic attributes.
- Source:
(static) init_2()
For game objects that do not define $template: true run the element initializer
and the per-object init event.
- Source:
(static) init_3()
Mark the object has having been fully initialized.
- Source:
(static) init_all()
Perform all initialization levels from 0..max_level as defined by RezGame.
This is intended for the author to call on a dynamically created object to ensure it is properly initialized before use.
- Source:
(static) isTemplateObject() → {boolean}
returns the value of the `$template` attribute
- Source:
Returns:
true if this object has a $template attribute with value true
- Type
- boolean
(static) needsArchiving() → {boolean}
- Source:
Returns:
true if this object requires archiving
- Type
- boolean
(static) removeEffect(effect_id, slot_id, item_id)
Parameters:
Name | Type | Description |
---|---|---|
effect_id |
string | |
slot_id |
string | |
item_id |
string |
- Source:
(static) runEvent(event_name, params) → {*|boolean}
attempts to run the event handler function for the event name, passing the specified params to the handler
Parameters:
Name | Type | Description |
---|---|---|
event_name |
string | name of the event to run, e.g. "speak" |
params |
object | object containing event params |
- Source:
Returns:
returns a response object, or false if the event was not handled
- Type
- * | boolean
(static) setAttribute(attr_name, new_value, notify_observers)
Parameters:
Name | Type | Description |
---|---|---|
attr_name |
string | name of attribute to set |
new_value |
* | value for attribute |
notify_observers |
boolean | whether observers should be notified that the value has changed |
- Source:
(static) setTags(tags)
Parameters:
Name | Type | Description |
---|---|---|
tags |
set | tags the object should have after the call |
- Source:
(static) willHandleEvent(event_name) → {boolean}
Returns `true` if this object defines an event handler function for the given event_name
Parameters:
Name | Type | Description |
---|---|---|
event_name |
string | name of the event to check for a handler, e.g. "speak" |
- Source:
Returns:
true if this object handles the specified event
- Type
- boolean