Difference between revisions of "Global Command: getObject"
From The Official Visionaire Studio: Adventure Game Engine Wiki
(Created page with "Get a Visionaire object. ''Note that in most cases it is no longer necessary to make use of this function, because Visionaire objects can now be accessed directly (since Visi...") |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Get a Visionaire object. | Get a Visionaire object. | ||
− | ''Note that in most cases it is no longer necessary to make use of this function, because Visionaire objects can now be accessed directly ( | + | ''Note that in most cases it is no longer necessary to make use of this function, because Visionaire objects can now be accessed directly ("shorthand notation").'' |
+ | |||
+ | {| class="ts" | ||
+ | |- | ||
+ | | style="width:15%" | Related functions | ||
+ | | [[VisionaireObject Command: getObject|TVisObj:getObject]] | ||
+ | |} | ||
Line 51: | Line 57: | ||
− | '''Example 2:''' Access a condition of a specific object. | + | '''Example 2:''' Access a condition of a specific object by passing the full path. |
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
− | local doorCond = getObject("Scenes[office]. | + | local doorCond = getObject("Scenes[office].SceneObjects[door].ObjectConditions[door_open?]") |
-- Note that the same can be achieved easier with the "shorthand" notation | -- Note that the same can be achieved easier with the "shorthand" notation | ||
− | local doorCond = Scenes["office"].Conditions["door_open?"] | + | local doorCond = Scenes["office"].Objects["door"].Conditions["door_open?"] |
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | '''Example 3:''' Access a character by passing a tuple: get object with id=3 from table with id=0 (characters table). | ||
+ | <syntaxhighlight lang="lua"> | ||
+ | local char = getObject("(0,3)") | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{toc}} | {{toc}} |
Latest revision as of 19:43, 11 August 2023
Get a Visionaire object.
Note that in most cases it is no longer necessary to make use of this function, because Visionaire objects can now be accessed directly ("shorthand notation").
Related functions | TVisObj:getObject |
Syntax
getObject(path_or_tuple [, logWarning])
Parameters
Parameter | Type | Description |
---|---|---|
path_or_tuple | string | Path to a Visionaire Object. The path has to start with a table name, followed by the object name in square brackets ([...]). The "game" table does not have object names. Optionally a field name (field type must either be "t_link" or "t_links") can follow after a dot. For "t_links" fields you must specify an object name in square brackets ([...]). Alternatively, you can pass in a tuple with the table id and the object id, e. g. "(0,3)". |
logWarning | boolean | If true a warning will be printed to the log file if the object could not be found. The default value is true. |
Return values
Type | Description |
---|---|
TVisObj | The Visionaire object or an empty object if no object was found. |
Examples
Example 1: Access a condition just by its name (name must be unique throughout the project).
local doorCond = getObject("Conditions[door_open?]")
-- Note that the same can be achieved easier with the "shorthand" notation
local doorCond = Conditions["door_open?"]
Example 2: Access a condition of a specific object by passing the full path.
local doorCond = getObject("Scenes[office].SceneObjects[door].ObjectConditions[door_open?]")
-- Note that the same can be achieved easier with the "shorthand" notation
local doorCond = Scenes["office"].Objects["door"].Conditions["door_open?"]
Example 3: Access a character by passing a tuple: get object with id=3 from table with id=0 (characters table).
local char = getObject("(0,3)")