Skip to main content

vrnode

Module: Node

A node in the tree.

#include <lua_api.h>

Public Functions​

TypeName
vrnodeancestor(string metaName)
(vrNodeGetAncestor) Gets the first ancestor of the specified type
vrnodechild(string metaType =0, string name =0)
(vrNodeGetChild) Gets the first child of a node.
vrnodechildbyindex(number idx)
(vrNodeGetChildByIndex) Gets a nodes child by its zero-based index. Note: this function may result in poor performance when iterating over lots of nodes - use vrNodeGetChild() and vrNodeGetSibling() instead (see the Best Practices section of the Programming Guide for more info).
numbercount()
(vrNodeGetChildCount) Counts the children of a node. Note: this function may result in poor performance when iterating over lots of nodes - use vrNodeGetChild() and vrNodeGetSibling() instead (see the Best Practices section of the Programming Guide for more info).
vrnodefind(string path, boolean caseSensitive =true)
(vrNodeFindChild) Finds a descendant of a node by path
voidforEachChild(Any function)
(vrNodeForEachChild) Calls a function for each child of a node
voidforEachChildOfType(string metaType, Any function)
(vrNodeForEachChildOfType) Calls a function for each child of a node that matches a specified type
stringgetName()
(vrNodeGetName) Gets the name of a node.
vrnodegetParent()
(vrNodeGetParent) Gets the parent of a node.
MULTI< vrvec3, vrvec3, vrvec3 >getRelative(string propName, vrnode otherNode)
(vrNodeGetRelativeTransform) Gets the position, rotation and scale of the world transform of one node relative to another.
booleanhasTrait(string traitName)
(vrNodeHasTrait) Checks if the node is of a type with a specific trait. This is a lot faster than vrNodeGetTraits
vrnodenext(string metaType =0, string name =0)
(vrNodeGetSibling) Gets the sibling (adjacent) node to a node.
vrnodeparent()
(vrNodeGetParent) Gets the parent of a node.
stringpath()
(vrNodeGetPath) Gets the encoded path to a node relative to the tree root
vrnodeprevious(string metaType =0, string name =0)
(vrNodeGetPreviousSibling) Gets the previous sibling (adjacent) node to a node.
stringrelpath(vrnode](../classes/vrnode.mdx) relativeTo)
(vrNodeGetRelativePath) Gets the encoded path to a node, relative to another node.
voidsetName(string newName)
(vrNodeSetName) Sets the name of a node.
voidsetParent(vrnode](../classes/vrnode.mdx) parent =nil, vrnode beforeSibling =nil, boolean preserveWorldTransform =false)
(vrNodeSetParent) Sets the parent of a node.
voidsetRelative(string propName, vrnode otherNode, Any vpos, Any vrot, Any vscale)
(vrNodeSetRelativeTransform) Sets the position, rotation and scale of the world transform of a node relative to another.
vrnodesibling(string metaType =0, string name =0)
(vrNodeGetSibling) Gets the sibling (adjacent) node to a node.
vrnodetail(string metaType =0, string name =0)
(vrNodeGetTail) Gets the last child of a node.
tabletraits()
(vrNodeGetTraits) Gets the list of traits that this node has. Can also be thought of as the base class of a node (e.g. Texture, Viewport, etc). This function is expensive and can affect performance. To check a specific trait use vrNodeHasTrait
stringtype(boolean versioned =false)
(vrNodeGetMetaNode) Gets the name of the MetaNode that a node is an instance of. This can also be referred to as the node type.

Public Functions Documentation​

ancestor​

vrnode ancestor(
string metaName
)

(vrNodeGetAncestor) Gets the first ancestor of the specified type

Parameters:

  • metaName The type of ancestor to look for

Return: Ancestor node of the specified type, or false if there isn't one

child​

vrnode child(
string metaType =0,
string name =0
)

(vrNodeGetChild) Gets the first child of a node.

Parameters:

  • metaType The type of child to get
  • name The name of the child to get

Return: The first child node, of the type in the metaType parameter, if specified, or false if there are no suitable child nodes

childbyindex​

vrnode childbyindex(
number idx
)

(vrNodeGetChildByIndex) Gets a nodes child by its zero-based index. Note: this function may result in poor performance when iterating over lots of nodes - use [vrNodeGetChild() and [vrNodeGetSibling() instead (see the Best Practices section of the Programming Guide for more info).

Parameters:

  • idx The index of the child (zero based)

Return: The specified child node, or false if out of range

count​

number count()

(vrNodeGetChildCount) Counts the children of a node. Note: this function may result in poor performance when iterating over lots of nodes - use [vrNodeGetChild() and [vrNodeGetSibling() instead (see the Best Practices section of the Programming Guide for more info).

Return: The number of direct child nodes

find​

vrnode find(
string path,
boolean caseSensitive =true
)

(vrNodeFindChild) Finds a descendant of a node by path

Parameters:

  • path The path or name of the node to search from
  • caseSensitive Whether to match case in the path

Return: The node at the specified path, or false if not found

forEachChild​

void forEachChild(
Any function
)

(vrNodeForEachChild) Calls a function for each child of a node

Parameters:

  • function The function to call for each child node. This function should have a signature of function(node). This can be a string name of a global function, or a lua function object. If the function returns a value other than nil, the function will not be called for further children and the value will be returned to the caller

forEachChildOfType​

void forEachChildOfType(
string metaType,
Any function
)

(vrNodeForEachChildOfType) Calls a function for each child of a node that matches a specified type

Parameters:

  • metaType The type of child nodes to find
  • function The function to call for each child node. This function should have a signature of function(node). This can be a string name of a global function, or a lua function object. If the function returns a value other than nil, the function will not be called for further children and the value will be returned to the caller

getName​

string getName()

(vrNodeGetName) Gets the name of a node.

Return: The name of the node

getParent​

vrnode getParent()

(vrNodeGetParent) Gets the parent of a node.

Return: The parent node

getRelative​

MULTI< vrvec3, vrvec3, vrvec3 > getRelative(
string propName,
vrnode otherNode
)

(vrNodeGetRelativeTransform) Gets the position, rotation and scale of the world transform of one node relative to another.

Return:

  • The relative world position
  • The relative world rotation
  • The relative world scale

hasTrait​

boolean hasTrait(
string traitName
)

(vrNodeHasTrait) Checks if the node is of a type with a specific trait. This is a lot faster than vrNodeGetTraits

Parameters:

  • traitName The name of the trait to check

Return: true if the node has the specified trait

next​

vrnode next(
string metaType =0,
string name =0
)

(vrNodeGetSibling) Gets the sibling (adjacent) node to a node.

Parameters:

  • metaType The type of sibling to get
  • name The name of the child to get

Return: The next sibling node, of the type in the metaType parameter, if specified, or false if there are no suitable siblings

parent​

vrnode parent()

(vrNodeGetParent) Gets the parent of a node.

Return: The parent node

path​

string path()

(vrNodeGetPath) Gets the encoded path to a node relative to the tree root

Return: The encoded path (special characters are encoded, e.g. space = %20)

previous​

vrnode previous(
string metaType =0,
string name =0
)

(vrNodeGetPreviousSibling) Gets the previous sibling (adjacent) node to a node.

Parameters:

  • metaType The type of sibling to get
  • name The name of the child to get

Return: The previous sibling node, of the type in the metaType parameter, if specified, or false if there are no suitable siblings

relpath​

string relpath(
vrnode relativeTo
)

(vrNodeGetRelativePath) Gets the encoded path to a node, relative to another node.

Parameters:

  • relativeTo The node to get the path relative to

Return: The encoded relative path (special characters are encoded, e.g. space = %20)

setName​

void setName(
string newName
)

(vrNodeSetName) Sets the name of a node.

Parameters:

  • newName The new name for the node

setParent​

void setParent(
vrnode parent =nil,
vrnode beforeSibling =nil,
boolean preserveWorldTransform =false
)

(vrNodeSetParent) Sets the parent of a node.

Parameters:

  • parent New parent. If this is nil, the parent is cleared, effectively deleting the node from the tree.
  • beforeSibling Specifies where to add the node in the parent's list of children, or nil to add it at the end of the list.
  • preserveWorldTransform If true, the node's position, rotation and scale in the world will be maintained.

setRelative​

void setRelative(
string propName,
vrnode otherNode,
Any vpos,
Any vrot,
Any vscale
)

(vrNodeSetRelativeTransform) Sets the position, rotation and scale of the world transform of a node relative to another.

Parameters:

  • vpos XYZ Position specified in a table {x, y, z}.
  • vrot Euler Rotation specified in a table {x, y, z}.
  • vscale XYZ Scale specified in a table {x, y, z}.

sibling​

vrnode sibling(
string metaType =0,
string name =0
)

(vrNodeGetSibling) Gets the sibling (adjacent) node to a node.

Parameters:

  • metaType The type of sibling to get
  • name The name of the child to get

Return: The next sibling node, of the type in the metaType parameter, if specified, or false if there are no suitable siblings

tail​

vrnode tail(
string metaType =0,
string name =0
)

(vrNodeGetTail) Gets the last child of a node.

Parameters:

  • metaType The type of child to get
  • name The name of the child to get

Return: The last child node, of the type in the metaType parameter, if specified, or false if there are no suitable child nodes

traits​

table traits()

(vrNodeGetTraits) Gets the list of traits that this node has. Can also be thought of as the base class of a node (e.g. Texture, Viewport, etc). This function is expensive and can affect performance. To check a specific trait use vrNodeHasTrait

Return: Array of traits that this node has

type​

string type(
boolean versioned =false
)

(vrNodeGetMetaNode) Gets the name of the MetaNode that a node is an instance of. This can also be referred to as the node type.

Parameters:

  • versioned Whether to get the full versioned metanode name rather than the unversioned name

Return: The node type