MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1 | SYNOPSIS |
Zesstra | b6ac9f6 | 2020-01-21 11:11:16 +0100 | [diff] [blame] | 2 | void say(string str) |
| 3 | void say(string str, object exclude) |
| 4 | void say(string str, object *excludes) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 5 | |
Zesstra | 5481d49 | 2021-04-08 20:07:06 +0200 | [diff] [blame] | 6 | void say(mixed *|mapping|struct|object|lwobject msg) |
| 7 | void say(mixed *|mapping|struct|object|lwobject msg, object exclude) |
| 8 | void say(mixed *|mapping|struct|object|lwobject msg, object *excludes) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 9 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 10 | DESCRIPTION |
| 11 | There are two major modes of calling: |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 12 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 13 | If the first argument is a string <str>, it will be send to |
| 14 | all livings in the current room except to the initiator. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 15 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 16 | If the first argument is an array/mapping/struct/object <msg>, the |
| 17 | lfun catch_msg() of all living objects except the initiator will be |
| 18 | called. |
| 19 | This <msg> will be given as first argument to the lfun, and |
| 20 | the initiating object as the second. |
| 21 | CAVEAT: If the lfun catch_msg() modifies the content of <msg>, all |
| 22 | subsequent objects will receive the modified <msg>. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 23 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 24 | By specifying a second argument to the efun one can exclude |
| 25 | more objects than just the initiator. If the second argument |
| 26 | is a single object <exclude>, both the given object and the |
| 27 | initiator are excluded from the call. If the second argument |
| 28 | is an array <excludes>, all objects and just the objects in |
| 29 | this array are excluded from the call. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 30 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 31 | The 'initiator' is determined according to these rules: |
| 32 | - if the say() is called from within a living object, this |
| 33 | becomes the initiator |
| 34 | - if the say() is called from within a dead object as result |
| 35 | of a user action (i.e. this_player() is valid), this_player() |
| 36 | becomes the initiator. |
| 37 | - Else the object calling the say() becomes the initiator. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 38 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 39 | EXAMPLES |
| 40 | say("Hi!\n"); |
| 41 | say("Hi!\n", this_player()); |
| 42 | Both calls are equal when called by a not living object. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 43 | |
| 44 | Object 1 (living): |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 45 | void catch_tell(string str) { |
| 46 | write("Received: "+str+"\n"); |
| 47 | } |
| 48 | Object 2 (not living): |
| 49 | void func() { |
| 50 | ... |
| 51 | say("HiHo!\n"); |
| 52 | ... |
| 53 | } |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 54 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 55 | This examples shows how say() together with catch_tell() |
| 56 | works. The 2nd object must not be living so the write() will |
| 57 | go to the current user. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 58 | |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 59 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 60 | Object 1 (living): |
| 61 | void catch_msg(mixed *arr, object who) { |
| 62 | int i; |
| 63 | if(!arr) return; |
| 64 | for(i=0; i<sizeof(arr); i++) |
| 65 | tell_object(who, (stringp(arr[i]) ? arr[i] : "-/-")+"\n"); |
| 66 | } |
| 67 | Object 2 (not living): |
| 68 | void func() { |
| 69 | ... |
| 70 | say( ({ "Hello", "there!" }) ); |
| 71 | ... |
| 72 | } |
Zesstra | b6ac9f6 | 2020-01-21 11:11:16 +0100 | [diff] [blame] | 73 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 74 | This is a bit complex example to demonstrate how say() and |
| 75 | catch_msg() works. Here we also use a non living object to |
| 76 | send the message so the who in catch_msg() will be the current |
| 77 | user. |
| 78 | |
| 79 | HISTORY |
| 80 | LDMud 3.3.686 added the use of a mapping/struct/object as second |
| 81 | argument. |
| 82 | |
| 83 | SEE ALSO |
Zesstra | b6ac9f6 | 2020-01-21 11:11:16 +0100 | [diff] [blame] | 84 | write(E), tell_object(E), tell_room(E) |