Skip to content

Api > MLMirror > BroadcastMessage()


MLMirror.BroadcastMessage(string methodName, any parameter = nil)⚓︎

Calls the method named methodName on every Lua Script in this game object or any of its children.

Parameters:⚓︎

Name Type Description
methodName string Name of the method to call.
parameter any Optional parameter to pass to the method (can be any value).

Usage⚓︎

---@type MLMirror
local mlmirror;

---@type string
local methodName;

---@type any
local parameter;


mlmirror.BroadcastMessage(methodName, parameter)

Example⚓︎

The Method needs to be attached to the Script object, similar to Start or Update functions.

do
    local script = LUA.script;
    function script.DoSomething()

    end

end
Call DoSomething function:

do
    local script = LUA.script;
    local component = SerializedField("Component", TYPE.OBJECT);

    function script.Start()
        component.BroadcastMessage("DoSomething");
    end
end