Skip to reading
BASIC Scripting

Send a message to another script

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page
On this page

BASIC IN YOUR GAME

One part of a game can announce that the bell rang. A different record can decide whether it cares about that bell.

The listening record#

Code example
ON OnCustomEvent THEN
    IF event.topic = "station_bell" THEN
        PRINT "Heard " & event.strikes & " strikes"
    END IF
END ON

Check OnCustomEvent for bell_listener and apply. In an ON block, the incoming dictionary is called event. The topic check lets this listener ignore other messages on the same event.

The sending record#

Code example
FUNCTION Run()
    EMIT EVENT "OnCustomEvent" WITH {"topic": "station_bell", "strikes": 2}
    RETURN TRUE
END FUNCTION

What you should see Running bell_sender dispatched the message. The listener printed Heard 2 strikes. Both records use the same topic text and the same field name, strikes.

Page 25 of 86Permalink
Go to page