blob: ae57bbea8ea5c1af9ac54ecfe89b233e4f7b81c7 [file] [log] [blame]
Bugfixb1d9b4d2021-09-14 20:07:04 +02001#pragma strict_types, save_types, pedantic, range_check
2#pragma no_clone
3
Bugfixb1d9b4d2021-09-14 20:07:04 +02004#include <thing/language.h>
5
6// Per Default nur an alle Items im Inventar weiterleiten.
7public 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
20private 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
32public varargs int* ReceiveSay(string msg, string prefix,
Zesstraf0425f82022-09-14 00:01:15 +020033 struct wave_s sense_blocked)
Bugfixb1d9b4d2021-09-14 20:07:04 +020034{
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
Zesstraf0425f82022-09-14 00:01:15 +020045public varargs int* ReceiveMultisense(struct wave_s msgs,
Bugfixb1d9b4d2021-09-14 20:07:04 +020046 string action, int commontypes)
47{
48 int** res = ({int**})all_inventory()->ReceiveMultisense(msgs, action, commontypes);
49 return _minarr(res);
50}