Instance
Instance : ``
Overview
Instance is the top parent class of all OVERDARE Lua classes.
Description
An instance is an abstract class that represents the elements composing a data model tree. It enables the storage and modification of parent and child relationships within a tree structure, as well as provides the properties necessary to access and differentiate instances. Instances allow for creation, destruction, and replication, and include features that facilitate locating or modifying instances deployed in the world. These features enable comparisons and modifications based on attributes such as tag, class names, instance names, and more.
Properties
Parent
Instance
The parent instance of that instance in the data model tree.
Code Samples
Archivable
bool
"Archivable" property is to determine whether an instance can be saved, restored, and preserved across gameplay sessions.
Code Samples
ClassName
string
Represents the Lua Class name of that instance.
Code Samples
Name
string
Represents the name of that instance. The Name
property is a user-defined string that identifies the instance within the hierarchy. It can be used to reference and differentiate instances programmatically.
Code Samples
Attributes
array
Store additional data or metadata related to the instances, allowing developers to customize and manage Lua attributes with flexibility.
Code Samples
LuaTags
array
Tags can be used to organize, categorize, filter, and search for instances within the context of Lua scripting.
Code Samples
Methods
Clone
This method creates a copy of the instance and its descendants (if any) in the data model tree. The cloned instance will be a separate entity and not linked to the original, but it retains the same properties, attributes, and child instances as the original at the time of cloning.
Parameters
Return
Instance
Code Samples
LuaDestroy
This method deletes (destroys) the instance from the data model tree. The LuaDestroy method removes the instance and its descendants (if any) from the hierarchy permanently. Note: Once an instance is destroyed, it cannot be recovered.
Parameters
Return
virtual void
Code Samples
FindFirstAncestor
An instance method used to find the first ancestor in the hierarchy by matching its name with the specified InName
parameter. This allows developers to traverse up the hierarchy to locate an instance with a specific name.
If no matching ancestor is found, the method returns nil
.
Parameters
string
InName
Return
Instance
Code Samples
FindFirstAncestorOfClass
Finds the first ancestor of the instance that matches the specified class name InClassName
. This method is useful for traversing up the object hierarchy to locate a specific class type.
Parameters
string
InClassName
The first ancestor that matches the specified class name, or nil if no match is found.
Return
Instance
Code Samples
FindFirstAncestorWhichIsA
Checks if the current instance is a descendant of another instance.
Parameters
string
InClassName
The class name to check against
Return
Instance
Code Samples
FindFirstChild
Finds the first child of the instance that matches the given name InName
. If the recursive
parameter is set to true
, the method searches through all descendants of the instance. If no matching child is found, the method returns nil
.
Parameters
string
InName
bool
recursive
Return
Instance
Code Samples
FindFirstChildOfClass
This method retrieves the first child of a given instance that matches the specified class name. If the bRecursive
parameter is set to true, the method searches all descendants of the instance to find a matching child. Returns the child instance if found; otherwise, it returns nil.
Parameters
string
InClassName
bool
bRecursive
Return
Instance
Code Samples
GetAttribute
Query the value of an attribute with a specific name.
Parameters
string
attribute
Return
Value
Code Samples
GetAttributes
Returns all attributes.
Parameters
Return
Value
Code Samples
GetChildren
The GetChildren method retrieves an array containing all direct children of the instance. This is useful for accessing immediate child objects without including descendants beyond the top level.
Parameters
Return
array
Code Samples
GetDescendants
The GetDescendants method retrieves an array containing all descendant objects of the instance, including both direct children and nested descendants at all levels.
Parameters
Return
array
Code Samples
IsDescendantOf
The IsDescendantOf method checks if the current instance is a descendant of the specified ancestor instance.
Parameters
Instance
InAncestor
Return
bool
Code Samples
LuaIsA
IsA method checks if an object is of a specified class name in Lua.
Parameters
string
InClassName
Return
bool
Code Samples
SetAttribute
Sets the value of an attribute with a specific key in it; if no attribute has that key, create and save a pair.
Parameters
string
attribute
Value
value
Return
void
Code Samples
WaitForChild
The WaitForChild method is used to pause the execution of the script until the specified child instance with the given name is found within the parent instance. This is especially useful in situations where you need to ensure that certain objects are loaded and available before proceeding with the rest of the script. An optional timeout period can also be specified to stop waiting after the given duration.
Parameters
string
InChildName
number
InTimeOut
Return
Instance
Code Samples
AddTag
The AddTag method appends or adds a tag to an Instance.
Parameters
FName
tag
Return
void
Code Samples
RemoveTag
Removes a specified tag from an object .
Parameters
FName
tag
Return
void
Code Samples
HasTag
The HasTag
method checks if an object has a specific tag.
Parameters
FName
tag
Return
bool
Code Samples
GetTags
The GetTags
method retrieves a list of all the tags currently applied to an instance.
Parameters
Return
array