Difference between revisions of "VisionaireObject Command: getLinks"

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 a table containing multiple VisionaireObjects.
<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 grouped data tables for objects, items, characters, conditions, & values etc...
+
== Syntax ==
 
+
<syntaxhighlight lang="lua">
 
+
getLinks(field)
<div class="toccolours mw-collapsible mw-collapsed tbl-ds">
 
<span class="bold">Additional Info</span>
 
<div class="mw-collapsible-content">
 
<div class="alt-bg">''!important'': The object names are case sensitive.</div>
 
<div>The data has to be iterated before you can access it.</div>
 
</div></div>
 
 
 
 
 
Syntax:
 
<syntaxhighlight>
 
getLinks(t_links)
 
</syntaxhighlight>
 
 
 
 
 
Example 1: using getLinks as initial function.
 
<syntaxhighlight>
 
local lang = game:getLinks(VGameLanguages) -- store all available game languages
 
 
 
-- * iterate the data * --
 
for i = 1, table.maxn(lang) do -- for i = 1 to amount of entries in lang table do...
 
print(lang[i]:getId().id .. ": " .. lang[i]:getName()) -- prints "language id: language name"
 
end
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Example 2: using getLinks after other functions
 
<syntaxhighlight>
 
local obj = getLink(VGameCurrentObject):getLinks(VObjectActions) -- get current item underneath the cursor & all actions associated with it...
 
  
-- * iterate the data * --
+
== Parameters ==
for i = 1, table.maxn(obj) do -- for i = 1 to amount of entries in obj table do...
 
print(i .. ": " .. obj[i]:getName()) -- prints "incremental value: action name"
 
end
 
</syntaxhighlight>
 
  
 +
{| class="ts"
 +
|-
 +
! style="width:15%" | Parameter
 +
! style="width:15%" | Type
 +
! Description
 +
|-
 +
| field
 +
| integer
 +
| The field which specifies a list of VisionaireObject links. The field type must be "t_links".
 +
''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>
 
  
'''t_links''': text <br/>
+
== Return values ==
The name of the grouped data structure object table.
 
  
 +
{| class="ts"
 +
|-
 +
! style="width:15%" | Type
 +
! Description
 +
|-
 +
| table
 +
| The table of VisionaireObjects (t_link values) linked in the field
 +
|}
  
<span class="bold underline">Flags</span>
 
  
none
+
== Examples ==
  
 +
'''Example 1:''' Print the names of all game languages to the log.
 +
<syntaxhighlight lang="lua">
 +
-- Specify the field constant name or the field id
 +
local lang = game:getLinks(VGameLanguages)
 +
local lang = game:getLinks(259)
  
<span class="bold underline">Return</span>
+
-- Iterate the table and print the language ids and names
 +
for i = 1, #lang do
 +
  print(lang[i]:getId().id .. ": " .. lang[i]:getName())
 +
end
  
'''object''' <br/>
+
-- The shorthand notation offers a more convenient way to achieve the same
Returns the data from the linked objects table; or returns empty.
+
local lang = game.Languages
  
{{i18n|GetLinks_(CMS)}}
+
for i = 1, #lang do
 +
  print(lang[i].id .. ": " .. lang[i].name)
 +
end
 +
</syntaxhighlight>
 +
{{toc}}

Latest revision as of 16:32, 25 August 2023

Returns a table containing multiple VisionaireObjects.


Syntax

getLinks(field)


Parameters

Parameter Type Description
field integer The field which specifies a list of VisionaireObject links. The field type must be "t_links".

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


Return values

Type Description
table The table of VisionaireObjects (t_link values) linked in the field


Examples

Example 1: Print the names of all game languages to the log.

-- Specify the field constant name or the field id
local lang = game:getLinks(VGameLanguages)
local lang = game:getLinks(259)

-- Iterate the table and print the language ids and names
for i = 1, #lang do
  print(lang[i]:getId().id .. ": " .. lang[i]:getName())
end

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

for i = 1, #lang do
  print(lang[i].id .. ": " .. lang[i].name)
end