Skip to content

API > LuaBehaviour


LuaBehaviour⚓︎

LuaBehaviour inherits from Behaviour

LuaBehaviour is the main class every Lua component script derives. When creating a Lua script in a component, you need to get and extend the instance of this object. This object references the component in which you attach your Lua script into.

Members⚓︎

Properties⚓︎

Name Description
LuaBehaviour.idPropertyReadonly Property A Unique identifier for this Lua script. This id is same for this script for all the clients in the room.

Methods⚓︎

Name Description
LuaBehaviour.StartCoroutine(coroutineFunction, args) Method Starts the passed function as a coroutine function.
LuaBehaviour.StopAllCoroutines() Method Stops all coroutines running on this behaviour.
LuaBehaviour.StopCoroutine(routine) Method Stops the coroutine reference by the Coroutine Object.

Messages⚓︎

Note

Massive Loop follows a similar messaging system as unity. The messages that listed here are sent by this component and must be used in a similar way as start or update functions.

Name Description
LuaBehaviour.FixedUpdate() Method Frame-rate independent message for physics calculations.
LuaBehaviour.LateUpdate() Method LateUpdate is called every frame.
LuaBehaviour.OnAnimatorIK(layerIndex) Method Callback for setting up animation IK (inverse kinematics).
LuaBehaviour.OnAnimatorMove() Method Callback for processing animation movements for modifying root motion.
LuaBehaviour.OnBecameInvisible() Method OnBecameInvisible is called when the object is no longer visible by any camera.
LuaBehaviour.OnBecameVisible() Method OnBecameVisible is called when the object became visible by any camera.
LuaBehaviour.OnBecomeOwner() Method Called when the current client becomes the owner of the object.
LuaBehaviour.OnCollisionEnter(other) Method OnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider.
LuaBehaviour.OnCollisionExit(other) Method OnCollisionExit is called when this collider/rigidbody has stopped touching another rigidbody/collider.
LuaBehaviour.OnCollisionStay(other) Method OnCollisionStay is called once per frame for every collider/rigidbody that is touching rigidbody/collider.
LuaBehaviour.OnDisable() Method This function is called when the behaviour becomes disabled.
LuaBehaviour.OnEnable() Method This function is called when the object becomes enabled and active.
LuaBehaviour.OnLostOwnership() Method Called when the current client loses the network ownership of the object.
LuaBehaviour.OnOwnerChanged(player) Method OnOwnerChanged called when the current Network owner is changed. The new owner is passed as argument. Network ownership allows a certain client to modify properties of a game object if that game object or any of its parent or grandparents are synchronized using MLSynchronizer.
LuaBehaviour.OnParticleCollision(gameObject) Method OnParticleCollision is called when a particle hits a Collider.
LuaBehaviour.OnTriggerEnter(other) Method When a GameObject collides with another GameObject, Unity calls OnTriggerEnter.
LuaBehaviour.OnTriggerExit(other) Method OnTriggerExit is called when the Collider other has stopped touching the trigger.
LuaBehaviour.OnTriggerStay(other) Method OnTriggerStay is called almost all the frames for every Collider other that is touching the trigger. The function is on the physics timer so it won't necessarily run every frame.
LuaBehaviour.Start() Method Start is called on the frame when a script is enabled just before any of the Update methods are called the first time.
LuaBehaviour.Update() Method Update is called every frame, if the component is enabled.

Inherited Members⚓︎

Inherited Properties⚓︎

Name Description
LuaBehaviour.enabledProperty Enabled Behaviours are Updated, disabled Behaviours are not.
LuaBehaviour.isActiveAndEnabledProperty Has the Behaviour had active and enabled called?
LuaBehaviour.gameObjectPropertyReadonly Property The game object this component is attached to. A component is always attached to a game object.
LuaBehaviour.tagPropertyReadonly Property The tag of this game object.
LuaBehaviour.transformPropertyReadonly Property The Transform attached to this GameObject.
LuaBehaviour.hideFlagsProperty Should the object be hidden, saved with the Scene or modifiable by the user?
LuaBehaviour.nameProperty The name of the object.

Inherited Methods⚓︎

Name Description
LuaBehaviour.BroadcastMessage(methodName, parameter=nil)Method Calls the method named methodName on every Lua Script in this game object or any of its children.
LuaBehaviour.CompareTag(tag)Method Is this game object tagged with tag ?
LuaBehaviour.GetAllLuaScripts()Method Returns an array of all Lua scripts that attached to the game object.
LuaBehaviour.GetComponent(type)Method Returns the component of Type type if the game object has one attached, nil if it doesn't.
LuaBehaviour.GetComponentInChildren(t)Method Returns the component of Type type in the GameObject or any of its children using depth first search.
LuaBehaviour.GetComponentInParent(t)Method Returns the component of Type type in the GameObject or any of its parents.
LuaBehaviour.GetComponents(type)Method Returns all components of Type type in the GameObject.
LuaBehaviour.GetComponentsInChildren(t)Method Returns all components of Type type in the GameObject or any of its children.
LuaBehaviour.GetComponentsInParent(t)Method Returns all components of Type type in the GameObject or any of its parents.
LuaBehaviour.SendMessage(methodName, value=nil)Method Calls the method named methodName on every Lua Script in this game object.
LuaBehaviour.SendMessageUpwards(methodName, value=nil)Method Calls the method named methodName on every LuaScript in this game object and on every ancestor of the behaviour.
LuaBehaviour.TryGetComponent(type)Method Gets the component of the specified type, if it exists.
LuaBehaviour.GetInstanceID()Method Returns the instance id of the object.

Example⚓︎

You can get the instance of the LuaBehaviour by calling ‘LUA.script’.

do
    ---@type LuaBehaviour
    local script = LUA.script;

end