Class:Instance

From OpenBlox
Jump to: navigation, search
This page is a translated version of the page Class:Instance and the translation is 100% complete.

Other languages:
Instance
abstract
Subclasses

The Instance class is the base class of the object system. All other classes inherit, either directly or indirectly, from this class. The members that are common to all the OpenBlox objects belong to the Instance class. This is why many of the most important and most used members belong to this class.

Properties

boolean Archivable

The value of this property determines whether the object can be serialized. The object will only be cloned or saved when this property is true. By default, this is true.[1]

string ClassName [read-only]

The value of this property is the name of the class (e.g. "Camera") the object belongs to. [2]

string Name

The value of this property is the name of this Instance. This property is used to determine which Instance, if any, will be returned when indexing an Instance. By default, Name is set to the ClassName of this Instance.

Instance Parent

The value of this property is the hierarchical parent of this Instance, in the scene graph. By default, this property is set to nil. [3]

Methods

void ClearAllChildren()

This method sets the parent of all the descendants of the object to nil.[4]

Instance Clone()

This method creates a new Instance of this class (if the Instance is Archivable and the class is not abstract or uncreatable), and sets all properties to the same value as this one. All children will be cloned as well, and their Parent property will be set to this Instance. [5] The Parent property of the Instance returned by this method will be nil.

If the Archivable property is set to false, or the class is abstract or uncreatable, this method will return nil.[6]

void Destroy()

This method is used to parent the object to nil and remove all references. All connections to events of this Instance will be disconnected. [7] Calling this method will parent-lock the Instance, meaning that the Instance's Parent property can not be changed after this method is called.[8]

void Remove()

This method sets the Parent property to nil, and recursively calls itself on children of this Instance.[9]

Instance FindFirstChild(string name, boolean recursive = false)

This method is used to find the first child of this Instance, with a given Name name. If recursive is true, this method will search all descendants of this Instance for the first Instance with the Name name.

Instance[] GetChildren()

This method returns all children of this Instance in an array.

string GetFullName()

This method returns the full name of this Instance. Usually in the form of game.Service.Thing, can return weird things when one of the parents of this Instance is parented to nil.

boolean IsA(string className)

This method returns true if this class inherits from the class of the given name, className. If there is no class with the name className, this method will always return false.

boolean IsAncestorOf(Instance otherInstance)

This method returns true if otherInstance is not nil and this Instance is an ancestor of otherInstance.

boolean IsDescendantOf(Instance otherInstance)

This method returns true if otherInstance is nil or this Instance is a descendant of otherInstance.

Events

AncestryChanged(Instance child, Instance parent)

This event is fired when the Parent property of this Instance, or one of its ancestors, is changed. child is the Instance whose Parent property changed, and parent is the new parent of child.

Changed(string property)

This event is fired when a property of this Instance is changed. property will be the name of the property that was changed.

ChildAdded(Instance kid)

This event is fired when a child is added to this Instance. kid is the new child.

ChildRemoved(Instance kid)

This event is fired when a child is removed from this Instance. kid is the Instance whose ancestry has been changed.

DescendantAdded(Instance descendant)

This event is fired when a descendant is added to this Instance. descendant is the descendant that has been added to this Instance's hierarchy.

DescendantRemoving(Instance descendant)

This event is fired when a descendant of this Instance is removed. descendant is the descendant that is being removed from this Instance.

References

  1. Instance.cpp, line 61.
  2. Ibid., line 62.
  3. Ibid., line 63.
  4. Ibid., line 200.
  5. Ibid., line 232.
  6. Ibid., line 222.
  7. Ibid., line 259.
  8. Ibid., line 257.
  9. Ibid., line 274.