Difference between revisions of "VisionaireObject Command: getLinks"

From The Official Visionaire Studio: Adventure Game Engine Wiki
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
<div class="toccolours mw-collapsible mw-collapsed tbl-ds">
 
<div class="toccolours mw-collapsible mw-collapsed tbl-ds">
<span class="bold">Command History</span>
+
<span class="bold">Function History</span>
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
 
<div class="alt-bg">Available since v3.0</div>
 
<div class="alt-bg">Available since v3.0</div>
Line 12: Line 12:
 
<span class="bold">Additional Info</span>
 
<span class="bold">Additional Info</span>
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<div class="alt-bg">''!important'': The object names are case sensitive.</div>
+
<div class="alt-bg">The data has to be iterated before you can access it.</div>
<div>The data has to be iterated before you can access it.</div>
 
 
</div></div>
 
</div></div>
  
Line 35: Line 34:
 
Example 2: using getLinks after other functions
 
Example 2: using getLinks after other functions
 
<syntaxhighlight>
 
<syntaxhighlight>
local obj = getLink(VGameCurrentObject):getLinks(VObjectActions) -- get current item underneath the cursor & all actions associated with it...
+
local obj = game: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
print(i .. ": " .. obj[i]:getName()) -- prints "incremental value: action name"
+
-- * 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>
Line 59: Line 61:
 
'''object''' <br/>
 
'''object''' <br/>
 
Returns the data from the linked objects table; or returns empty.
 
Returns the data from the linked objects table; or returns empty.
 
{{i18n|GetLinks_(CMS)}}
 

Revision as of 16:26, 22 March 2014

Function 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 = game: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.