Skip to content

Sending Custom Events to a Script

Sometimes you want to send messages to a script from another script. We provide a simple way of doing so:

Sending Script

1
2
3
4
5
6
7
8
9
global OTHER_SCRIPT = nil
function Start()
    OTHER_SCRIPT = BoundObjects["OtherGameObject"].GetComponent
end

-- See https://developers.abinteractive.net/cck/lua/api/events/#mouse-events
function OnMouseDown()
    OTHER_SCRIPT.CallReceiverFunction("Click", {Script.Hash})
end

Receiving Script

1
2
3
function RECEIVE_Click(args)
    print("Got a click!")
end