Skip to main content

LuaBehaviour

info

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

NameDescription
LuaBehaviour.idA Unique identifier for this Lua script. This id is same for this script for all the clients in the room.

Methods

NameDescription
LuaBehaviour.StartCoroutine(coroutineFunction, args)Starts the passed function as a coroutine function.
LuaBehaviour.StopAllCoroutines()Stops all coroutines running on this behaviour.
LuaBehaviour.StopCoroutine(routine)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.

NameDescription
LuaBehaviour.FixedUpdate()Frame-rate independent message for physics calculations.
LuaBehaviour.LateUpdate()LateUpdate is called every frame.
LuaBehaviour.OnAnimatorIK(layerIndex)Callback for setting up animation IK (inverse kinematics).
LuaBehaviour.OnAnimatorMove()Callback for processing animation movements for modifying root motion.
LuaBehaviour.OnBecameInvisible()OnBecameInvisible is called when the object is no longer visible by any camera.
LuaBehaviour.OnBecameVisible()OnBecameVisible is called when the object became visible by any camera.
LuaBehaviour.OnBecomeOwner()Called when the current client becomes the owner of the object.
LuaBehaviour.OnCollisionEnter(other)OnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider.
LuaBehaviour.OnCollisionExit(other)OnCollisionExit is called when this collider/rigidbody has stopped touching another rigidbody/collider.
LuaBehaviour.OnCollisionStay(other)OnCollisionStay is called once per frame for every collider/rigidbody that is touching rigidbody/collider.
LuaBehaviour.OnDisable()This function is called when the behaviour becomes disabled.
LuaBehaviour.OnEnable()This function is called when the object becomes enabled and active.
LuaBehaviour.OnLostOwnership()Called when the current client loses the network ownership of the object.
LuaBehaviour.OnOwnerChanged(player)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)OnParticleCollision is called when a particle hits a Collider.
LuaBehaviour.OnTriggerEnter(other)When a GameObject collides with another GameObject, Unity calls OnTriggerEnter.
LuaBehaviour.OnTriggerExit(other)OnTriggerExit is called when the Collider other has stopped touching the trigger.
LuaBehaviour.OnTriggerStay(other)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()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()Update is called every frame, if the component is enabled.

Inherited Members

Inherited Properties

NameDescription
LuaBehaviour.enabledEnabled Behaviours are Updated, disabled Behaviours are not.
LuaBehaviour.isActiveAndEnabledHas the Behaviour had active and enabled called?
LuaBehaviour.gameObjectThe game object this component is attached to. A component is always attached to a game object.
LuaBehaviour.tagThe tag of this game object.
LuaBehaviour.transformThe Transform attached to this GameObject.
LuaBehaviour.hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
LuaBehaviour.nameThe name of the object.

Inherited Methods

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