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: | ||
− | + | Returns a table containing multiple VisionaireObjects. | |
− | |||
− | |||
− | |||
− | |||
− | + | == Syntax == | |
− | + | <syntaxhighlight lang="lua"> | |
− | + | getLinks(field) | |
− | |||
− | |||
− | |||
− | < | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | getLinks( | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | == Parameters == | |
− | |||
− | |||
− | |||
− | |||
+ | {| 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.'' | ||
+ | |} | ||
− | |||
− | + | == Return values == | |
− | |||
+ | {| class="ts" | ||
+ | |- | ||
+ | ! style="width:15%" | 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. | ||
+ | <syntaxhighlight lang="lua"> | ||
+ | -- 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 | ||
+ | </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