MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1 | SYNOPSIS |
| 2 | void heart_beat() |
| 3 | |
| 4 | DESCRIPTION |
| 5 | This function will be called automatically every |
| 6 | __HEART_BEAT_INTERVAL__ seconds. The driver will call the function |
| 7 | directly in the object, even if the function is being shadowed. |
| 8 | |
| 9 | The start and stop of heart beat is controlled by the efun |
| 10 | set_heart_beat(). Be careful not to have objects with heart |
| 11 | beat running all the time, as it uses a lot of driver |
| 12 | resources. If there is an error in the heart beat routine, the |
| 13 | heart beat will be turned off for this object and the |
| 14 | master function heart_beat_error() is called. If the call |
| 15 | to the master function returns a non-zero value, the heart beat |
| 16 | will be turned back on again. |
| 17 | |
| 18 | The function this_player() will return this object, but only if |
| 19 | it is living. Otherwise, this_player() will return 0. |
| 20 | |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 21 | Note that error messages will be given to the current user |
| 22 | which will be the object itself or nobody. |
| 23 | |
| 24 | EXAMPLE |
| 25 | object owner; |
| 26 | void create() { |
| 27 | ... |
| 28 | owner=this_player(); |
| 29 | set_heart_beat(1); |
| 30 | } |
| 31 | void heart_beat() { |
| 32 | tell_object(owner, "Your heart goes: BUM BUM\n"); |
| 33 | } |
| 34 | |
| 35 | We have to use tell_object() because write goes to the current |
| 36 | user and this can only be the object itself or nobody. |
| 37 | |
| 38 | HISTORY |
| 39 | LDMud 3.3.687 made the interval time configurable at driver compile |
| 40 | time (used to be 2 seconds fixed). |
| 41 | |
| 42 | SEE ALSO |
| 43 | set_heart_beat(E), call_out(E), enable_commands(E), |
| 44 | heart_beat_error(M) |