Skip to content

API > Script


[Obsolete] Script⚓︎

The Script is Obsolete! Use LuaBehaviour

The script object references the Lua script that is attached to the game object. From the script, you access the underlying game object and the callback functions.

Members⚓︎

Properties⚓︎

Name Description
Script.gameObjectPropertyReadonly Property The GameObejct which this script attached to.
Script.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
Script.GetComponent(type) Method Returns the component of Type type if the game object has one attached, null if it doesn't.
Script.StartCoroutine(coroutineFunction, args) Method Starts the passed function as a coroutine function.

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
Script.FixedUpdate() Method Frame-rate independent FixedUpdate message for physics calculations. Similar to Unity Fixed Update
Script.LateUpdate() Method LateUpdate is called after all Update functions have been called.
Script.OnBecomeOwner() Method Called when the current client becomes the owner of the object.
Script.OnLostOwnership() Method Called when the current client loses the network ownership of the object.
Script.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.
Script.Start() Method Called once at the beginning of the game.
Script.Update() Method Called once every frame.

Example⚓︎

do -- script Object

    -- Get the reference for current script
    local script = LUA.Script;

    -- start only called at beginning
    function script.start()


    end

    -- update called every frame
    function script.update()


    end
end