Bugfix | b1d9b4d | 2021-09-14 20:07:04 +0200 | [diff] [blame] | 1 | #pragma strict_types, save_types, pedantic, range_check |
| 2 | #pragma no_clone |
| 3 | |
Bugfix | b1d9b4d | 2021-09-14 20:07:04 +0200 | [diff] [blame] | 4 | #include <thing/language.h> |
| 5 | |
| 6 | // Per Default nur an alle Items im Inventar weiterleiten. |
| 7 | public varargs int ReceiveMsg(string msg, int msg_type, string msg_action, |
| 8 | string msg_prefix, object origin) |
| 9 | { |
| 10 | int *res = ({int*})all_inventory()->ReceiveMsg(msg, msg_type, msg_action, |
| 11 | msg_prefix, |
| 12 | origin || previous_object()); |
| 13 | if (sizeof(res)) |
| 14 | return min(res); |
| 15 | return 0; |
| 16 | } |
| 17 | |
| 18 | // Sortierfunktion um das Array mit dem kleinsten Wert auszugeben |
| 19 | |
| 20 | private int* _minarr(int** arr) |
| 21 | { |
| 22 | if(!sizeof(arr)) return 0; |
| 23 | return sort_array(&arr, |
| 24 | function int(int* a, int* b) |
| 25 | { |
| 26 | return a[0] > b[0]; |
| 27 | })[0]; |
| 28 | } |
| 29 | |
| 30 | // Wrapper fuer ReceiveMsg() |
| 31 | |
| 32 | public varargs int* ReceiveSay(string msg, string prefix, |
Zesstra | f0425f8 | 2022-09-14 00:01:15 +0200 | [diff] [blame^] | 33 | struct wave_s sense_blocked) |
Bugfix | b1d9b4d | 2021-09-14 20:07:04 +0200 | [diff] [blame] | 34 | { |
| 35 | // Das muss schon hier passieren, damit previous_object() stimmt |
| 36 | if(!prefix) |
| 37 | { |
| 38 | prefix = ({string})previous_object().Name(WER, 1) + " sagt: "; |
| 39 | } |
| 40 | |
| 41 | int** res = ({int**})all_inventory()->ReceiveSay(msg, prefix, sense_blocked); |
| 42 | return _minarr(res); |
| 43 | } |
| 44 | |
Zesstra | f0425f8 | 2022-09-14 00:01:15 +0200 | [diff] [blame^] | 45 | public varargs int* ReceiveMultisense(struct wave_s msgs, |
Bugfix | b1d9b4d | 2021-09-14 20:07:04 +0200 | [diff] [blame] | 46 | string action, int commontypes) |
| 47 | { |
| 48 | int** res = ({int**})all_inventory()->ReceiveMultisense(msgs, action, commontypes); |
| 49 | return _minarr(res); |
| 50 | } |