MUDL:timer process queue

From SlothMUD Wiki
Jump to: navigation, search


Summary

Function Name timer_process_queue
Settable No
Returns Boolean


Parameter Options
Queue Name (string), Callback function name (string), Context (string)


This function processes the set of KVP keys and values created by previous calls to timer_add_event. Each event stored in the KVP is checked to see if it is time to process. When it is time, if the previous target is still in the game, the user provided callback function is called to process the event. If the target of the event (mobile, object, room, area) has been destroyed, the event is discarded. If a player is the target of the event and logs out, the event is suspended and will execute the next time the player logs in. Events do not persist across reboots.


The user callback function takes a different form depending on the type of the target object. All callback functions return a boolean - even though this return value is ignored.


Callback prototypes
No target fn_b_MyCallbackFunctionName_ss
Character fn_b_MyCallbackFunctionName_css
Item fn_b_MyCallbackFunctionName_oss
Room fn_b_MyCallbackFunctionName_rss
Area fn_b_MyCallbackFunctionName_zss


The first string parameter is the data passed as the last parameter to the add_timer_event function. The second string is the context string passed as the last parameter to timer_process_queue.


Key Value Pairs

Arguments
<Queue Name>_INDEX An integer value that tracks the key name for the next queued element.
<Queue Name>_ELEMENT_<Number> A specially formatted value containing a single element in the queue. Currently the value contains 5 entries separated by colons.


Example

To destroy a mobile in 300 seconds.

addproc <mobile> mudl

setproc <mobile> # on_yell
timer_add_event(%c, 0, 'MY_QUEUE', 300, %c, 'My Data')
@


setproc <mobile> # timer_1
timer_process_queue('MY QUEUE', 'DestroyMob', 'My Context')
@


setproc <mobile> # fn_b_DestroyMob_css
msg_room(room(%1), '$n explodes in a cloud of dust!', %1),
destroy(%1)
@