Difference between revisions of "VisionaireObject Command: getLink"

From The Official Visionaire Studio: Adventure Game Engine Wiki
m (Text replacement - "{{toc}}" to "")
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{| class="toccolours mw-collapsible mw-collapsed ts"
+
Returns the VisionaireObject which is linked in a VisionaireObject field.
|-
 
! Function History
 
|-
 
| Available since v3.0
 
|}
 
 
 
 
 
Allows you to access, read & manipulate the data tables for objects, items, characters, conditions, & values etc...
 
  
  
Syntax:
+
== Syntax ==
<syntaxhighlight>
+
<syntaxhighlight lang="lua">
getLink(t_link)
+
getLink(field)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
  
Example 1: using getLink as initial function.
+
== Parameters ==
<syntaxhighlight>
 
game:getLink(VGameCurrentCharacter) -- access all tables of current character
 
game:getLink(VGameCurrentScene) -- access all tables of current scene
 
</syntaxhighlight>
 
  
Example 2: using getLink after other functions
+
{| class="ts"
<syntaxhighlight>
+
|-
game:getLink(VGameCurrentCharacter):getLink(VCharacterCurrentOutfit) -- access table of current characters active outfit
+
! style="width:15%" | Parameter
getObject("Characters[Tom]"):getLink(VCharacterCurrentOutfit) -- access active outfit table of character "Tom"
+
! style="width:15%" | Type
</syntaxhighlight>
+
! 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 ==
  
'''t_link''': text <br/>
+
{| class="ts"
The name of the data structure object table.
+
|-
 +
! style="width:15%" | Type
 +
! Description
 +
|-
 +
| TVisObj
 +
| The VisionaireObject linked in the field or an empty object if no object is linked
 +
|}
  
  
<span class="bold underline">Flags</span>
+
== Examples ==
  
none
+
'''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)
  
 
+
-- The shorthand notation offers a more convenient way to achieve the same
<span class="bold underline">Return</span>
+
local curr_char = game.CurrentCharacter
 
+
</syntaxhighlight>
'''object''' <br/>
+
{{toc}}
Returns the data from the linked objects table; or returns empty.
 

Latest revision as of 23:45, 11 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