Difference between revisions of "VisionaireObject Command: getLinks"
From The Official Visionaire Studio: Adventure Game Engine Wiki
Line 34: | Line 34: | ||
Example 2: using getLinks after other functions | Example 2: using getLinks after other functions | ||
<syntaxhighlight> | <syntaxhighlight> | ||
− | local obj = getLink(VGameCurrentObject) | + | local obj = getLink(VGameCurrentObject) |
− | -- * iterate the data * -- | + | if not obj:isEmpty() then -- if obj is not empty do... |
− | for i = 1, table.maxn(obj) do -- for i = 1 to amount of entries in obj table do... | + | if obj:getId().tableId == eCharacters then obj = obj:getLinks(VCharacterActions) else obj = obj:getLinks(VObjectActions) end -- check if obj is a character or an object |
− | + | -- * iterate the data * -- | |
+ | 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 | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 18:21, 19 March 2014
Command History
Available since v3.0
Allows you to access, read & manipulate grouped data tables for objects, items, characters, conditions, & values etc...
Additional Info
The data has to be iterated before you can access it.
Syntax:
getLinks(t_links)
Example 1: using getLinks as initial function.
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
Example 2: using getLinks after other functions
local obj = getLink(VGameCurrentObject)
if not obj:isEmpty() then -- if obj is not empty do...
if obj:getId().tableId == eCharacters then obj = obj:getLinks(VCharacterActions) else obj = obj:getLinks(VObjectActions) end -- check if obj is a character or an object
-- * iterate the data * --
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
end
Arguments
t_links: text
The name of the grouped data structure object table.
Flags
none
Return
object
Returns the data from the linked objects table; or returns empty.