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...") |
|||
Line 53: | Line 53: | ||
'''Example 2:''' Access a condition of a specific object. | '''Example 2:''' Access a condition of a specific object. | ||
<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> | </syntaxhighlight> | ||
{{toc}} | {{toc}} |
Revision as of 12:43, 19 May 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 (since Visionaire Studio version 5.0).
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.
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?"]