Difference between revisions of "VisionaireObject Command: getLink"

From The Official Visionaire Studio: Adventure Game Engine Wiki
(Created page with "<div class="toccolours mw-collapsible mw-collapsed tbl-ds"> <span class="bold">Command History</span> <div class="mw-collapsible-content"> <div class="alt-bg">Available since ...")
 
 
(9 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<div class="toccolours mw-collapsible mw-collapsed tbl-ds">
+
Returns the VisionaireObject which is linked in a VisionaireObject field.
<span class="bold">Command History</span>
 
<div class="mw-collapsible-content">
 
<div class="alt-bg">Available since v3.0</div>
 
</div></div>
 
  
  
Allows you to access, read & manipulate the data tables for general game objects, items, characters, conditions, & values etc...
+
== Syntax ==
 
+
<syntaxhighlight lang="lua">
'''''* this page is a work in progress *'''''
+
getLink(field)
 
 
Syntax:
 
<syntaxhighlight>
 
getLink(table)
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
  
Example 1: Quick getObject method; you must take care when using this method, that your project does not contain multiple objects with the same name.
+
== Parameters ==
<syntaxhighlight>
 
-- This method is unsafe because it accesses all the condition/value tables associated with the project
 
getObject("Conditions[condition_name]") -- get a condition
 
getObject("Values[value_name]") -- get a value
 
getObject("Actions[action_name]") -- get an action
 
getObject("Animations[animation_name]") -- get an animation
 
</syntaxhighlight>
 
 
 
Example 2: Full getObject method.
 
<syntaxhighlight>
 
-- * scenes * --
 
getObject("Scenes[scene_name].SceneConditions[condition_name]") -- get condition linked to a scene
 
getObject("Scenes[scene_name].SceneObjects[object_name].ObjectConditions[condition_name]") -- get condition linked to a scene object
 
getObject("Scenes[scene_name].SceneValues[value_name]") -- get value linked to a scene
 
getObject("Scenes[scene_name].SceneObjects[object_name].ObjectValues[value_name]") -- get value linked to a scene object
 
getObject("Scenes[scene_name].SceneActions[action_name]") --
 
getObject("scenes[scene_name].SceneObjects[object_name].ObjectAnimations[animation_name]") -- get animation linked to a scene object
 
-- * characters * --
 
getObject("Characters[character_name].CharacterConditions[condition_name]") -- get condition linked to a character
 
getObject("Characters[character_name].CharacterValues[value_name]") -- get value linked to a character
 
getObject("Characters[character_name].CharacterActions[action_name]") -- get action linked to a character
 
getObject("Characters[character_name].CharacterOutfits[outfit_name].OutfitCharacterAnimations[animation_name]") -- get animation linked to a character
 
-- etc...
 
</syntaxhighlight>
 
  
 +
{| class="ts"
 +
|-
 +
! style="width:15%" | Parameter
 +
! style="width:15%" | Type
 +
! Description
 +
|-
 +
| field
 +
| integer
 +
| The field which specifies a VisionaireObject link. The field type must be "t_link".
 +
''Specify the field constant name (V + object table name in singular + field name) or the field id, see the example.''
 +
|}
  
  
<span class="bold underline">Arguments</span>
+
== Return values ==
  
'''path''': "string" <br/>
+
{| class="ts"
The path to the required data structure object.
+
|-
 +
! style="width:15%" | Type
 +
! Description
 +
|-
 +
| TVisObj
 +
| The VisionaireObject linked in the field or an empty object if no object is linked
 +
|}
  
'''object''': text<br/>
 
Name of the object, character, condition etc; the name is case sensitive.
 
  
'''error''': bool (true/false) <br/>
+
== Examples ==
If <span class="green">''true''</span> a warning will be printed to the log, if the linked object can not be found; it is set to <span class="green">true</span>, by default.
 
  
 +
'''Example 1:''' Get the currently playable character.
 +
<syntaxhighlight lang="lua">
 +
-- Specify the field constant name or the field id
 +
local curr_char = game:getLink(VGameCurrentCharacter)
 +
local curr_char = game:getLink(468)
  
<span class="bold underline">Flags</span>
+
-- The shorthand notation offers a more convenient way to achieve the same
 
+
local curr_char = game.CurrentCharacter
none
+
</syntaxhighlight>
 
+
{{toc}}
 
 
<span class="bold underline">Return</span>
 
 
 
'''object''' <br/>
 
Returns the data from the linked objects table; or returns empty.
 
 
 
{{i18n|GetObject_(CMS)}}
 

Latest revision as of 00:45, 12 August 2023

Returns the VisionaireObject which is linked in a VisionaireObject field.


Syntax

getLink(field)


Parameters

Parameter Type Description
field integer The field which specifies a VisionaireObject link. The field type must be "t_link".

Specify the field constant name (V + object table name in singular + field name) or the field id, see the example.


Return values

Type Description
TVisObj The VisionaireObject linked in the field or an empty object if no object is linked


Examples

Example 1: Get the currently playable character.

-- Specify the field constant name or the field id
local curr_char = game:getLink(VGameCurrentCharacter)
local curr_char = game:getLink(468)

-- The shorthand notation offers a more convenient way to achieve the same
local curr_char = game.CurrentCharacter