Skip to content

Object

An object created from the class.new() function. Contains all of the members given from the class object.

Warning

objects act as a proxy, as they belong to the base type userdata. They allow access to members in the objectData, but they cannot be changed. This is to make access-specifiers work in the best way possible.


Summary

Properties

  • __locked: Indicates if the object is locked.
  • __type: Indicates the type of the object.
  • __objtype: Indicates the class type of the object.

Methods

  • constructor: The constructor function of the object, if it exists. Cannot be directly called.
  • destructor: The destructor function of the object, if it exists. Cannot be directly called.
  • Destroy: Calls the destructor function, destroys all the instances inside the objectData and clears it, and sets the __locked property to true.
  • super: Calls the method with the same name of the function that it's been called from in the parent class, if it exists.

Properties

__locked : boolean
Internal

Indicates if an object has been locked. If set to true, the object's metamethods will no longer work and all the members will become unaccessable.


__type : string
Internal

Indicates the type of the object. For objects created from class.new(), it will always be "Object".


__objtype : string
Internal

Indicates the class type of the object. Can be used to determine which class the object belongs to by using the Type.typeof() function.


Methods

constructor : void
Internal

The constructor function of the object, if it has been set in the classData table. This function is internal, and it will only be called when the object is created by using the class.new() function.

Returns

void


destructor : void
Internal

The destructor function of the object, if it has been set in the classData table. This function accepts no parameters and is internal, it will only be called when object:Destroy() is called.

Returns

void


Destroy : void

Calling this method will destroy and clean the object. This method will first trigger the destructor function, then after, it will clear the internal objectData table and set the __locked property of the object to true. Instances inside objectData will automatically be destroyed and cleared too.

After this function runs, the object will no longer be accessible in any way, so make sure to remove all references to the object to allow for the garbage collector to clear it. This prevents memory leaks.

Returns

void


super : any

This method allows you to refer to the parent class's methods. Calling this method will call the function with the same name as the function it's been called from in the parent class, if it exists, and return the result.

Warning

super does not support being called in classes created from multi-inheritance, as it would create ambiguity. It also does not support calling functions that are defined in the Private access-specifier in the parent class.