User Tools

Site Tools


4rpl:commands:registerformsg

This is an old revision of the document!


REGISTERFORMSG

RegisterforMsg(<-channel <-callbackFunction)

Description

Registers a script to receive callbacks whenever somethings sends a message to 'channel'. The channel is just a string.
Callbacks are made at the time sending happens. Note that some callbacks can be made from system objects, like the InfoCache.
The callback is made to the function specified by 'callbackFunction'. It is not case sensitive. A var named “_DATA” will be set before the function is invoked on the script. That var can have any type, it depends what type the sender sent.
Messages are registered by channel. So if you call RegisterForMsg more than once with the same channel, but different callbackFunctions, only one registration is performance. Subsequent calls to register on the same channel will replace any previous registrations.
RegisterForMSG is persistent, so you only need to call it once.

Examples

:once
   RegisterForMSG("test" "MyCallback")
 
:MYCALLBACK
   PrintallSP("Callback: " <-_DATA)
4rpl/commands/registerformsg.1589462870.txt.gz · Last modified: 2025/02/14 14:56 (external edit)