VisionaireObject Command: getParent

From The Official Visionaire Studio: Adventure Game Engine Wiki
Revision as of 20:10, 31 August 2023 by EK (talk | contribs) (Created page with "Returns the parent object of the VisionaireObject. == Syntax == <syntaxhighlight lang="lua"> getParent() </syntaxhighlight> == Parameters == none == Return values == {...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Returns the parent object of the VisionaireObject.


Syntax

getParent()


Parameters

none


Return values

Type Description
TVisObj The parent object of the VisionaireObject.


Examples

Example 1: Check if an animation belongs to a character or not.

function checkAnimOwner(anim)
  anim = getObject("Animations[" .. anim .. "]")

  if anim:getParent():getId().tableId == eOutfits then
    print("The animation with id=" .. anim:getId().id .. " is a character animation.")
  else
    print("The animation with id=" .. anim:getId().id .. " is not a character animation.")
  end
end

checkAnimOwner("welding_anim")

-- The shorthand notation offers a more convenient way to achieve the same
function checkAnimOwner(anim)
  anim = Animations[anim]

  if anim.parent.tableId == eOutfits then
    print("The animation with id=" .. anim.id .. " is a character animation")
  else
    print("The animation with id=" .. anim.id .. " is not a character animation")
  end
end

checkAnimOwner("welding_anim")