Difference between revisions of "VisionaireObject Command: getLink"

From The Official Visionaire Studio: Adventure Game Engine Wiki
 
(7 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(t_link)
 
</syntaxhighlight>
 
 
 
 
 
Example 1: using getLink as initial function.
 
<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
 
<syntaxhighlight>
 
game:getLink(VGameCurrentCharacter):getLink(VCharacterCurrentOutfit) -- access table of current characters active outfit
 
getObject("Characters[Tom]"):getLink(VCharacterCurrentOutfit) -- access active outfit table of character "Tom"
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
  
<span class="bold underline">Arguments</span>
+
== Parameters ==
  
'''t_link''': text <br/>
+
{| class="ts"
The name of the data structure object table.
+
|-
 +
! 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">Flags</span>
+
== Return values ==
  
none
+
{| class="ts"
 +
|-
 +
! 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">Return</span>
+
== Examples ==
  
'''object''' <br/>
+
'''Example 1:''' Get the currently playable character.
Returns the data from the linked objects table; or returns empty.
+
<syntaxhighlight lang="lua">
 +
-- Specify the field constant name or the field id
 +
local curr_char = game:getLink(VGameCurrentCharacter)
 +
local curr_char = game:getLink(468)
  
{{i18n|GetLink_(CMS)}}
+
-- The shorthand notation offers a more convenient way to achieve the same
 +
local curr_char = game.CurrentCharacter
 +
</syntaxhighlight>
 +
{{toc}}

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