forked from fuzzball-muck/fuzzball-muf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib-mesg.muf
238 lines (204 loc) · 5.71 KB
/
lib-mesg.muf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
@prog lib-mesg
1 99999 d
1 i
( **** Message Object -- MSG- ****
A message is a set of elements with a count and an information string,
stored in properties.
base is a string containing the name of the message.
itemnum is the number of an item within a message.
itemstr is a single item's string.
infostr is the messages information string.
{strrange} is a string range that is all the elements of the message
with an integer count.
MSG-destroy [base dbref -- ]
Clears and removes the message.
MSG-create [{strrange} infostr base dbref -- ]
Create a new message with the given items and info string on
the given object with the given name.
MSG-count [base dbref -- count]
Returns how many items are in the given message.
MSG-info [base dbref -- infostr]
Returns the information string for the given message.
MSG-setinfo [infostr base dbref -- ]
Sets the information string on an existing message.
MSG-message [base dbref -- {strrange}]
Returns the items of a message as a range on the stack.
MSG-item [itemnum base dbref -- itemstr]
Returns the given message item from the message.
MSG-setitem [itemstr itemnum base dbref -- ]
Sets the specified message item to the given string.
MSG-insitem [itemstr itemnum base dbref -- ]
Inserts a new message item into the message at the given point.
MSG-append [itemstr base dbref -- ]
Appends a message item to the given message.
MSG-delitem [itemnum base dbref -- ]
Deletes the specified message item from the given message.
Message data type:
Base# Count of Message Items
Base#/X Message Items
Base#/i Info String
)
( $def the following if your muck uses the new style propdirized lists )
( ie: listname#/1:line one listename#/2:line two etc. )
$def SLASHED_LISTS
$include $lib/props
$include $lib/lmgr
: MSG-destroy (base dbref -- )
$ifdef SLASHED_LISTS
over over swap "#/i" strcat remove_prop
$else
swap "/" strcat
over over "i" strcat remove_prop
swap
$endif
LMGR-deletelist
;
: MSG-setinfo (infostr base dbref -- )
swap
$ifdef SLASHED_LISTS
"#" strcat
$endif
"/i" strcat rot setpropstr
;
: MSG-create ({strrange} infostr base dbref -- )
over over MSG-destroy
rot 3 pick 3 pick MSG-setinfo
({strrange} base dbref)
1 rot rot
$ifndef SLASHED_LISTS
swap "/" strcat swap
$endif
LMGR-putrange
;
: MSG-count (base dbref -- count)
$ifndef SLASHED_LISTS
swap "/" strcat swap
over over LMGR-getcount
dup if
rot rot pop pop exit
else pop
then
$endif
LMGR-getcount
;
: MSG-message (base dbref -- {strrange})
$ifndef SLASHED_LISTS
swap "/" strcat swap
over over lmgr-getlist
dup if
dup 2 + rotate pop
dup 2 + rotate pop
exit
else pop
then
$endif
LMGR-getlist
;
: safeclear (d s -- )
over over propdir? if
over over "" -1 addprop
"" 0 addprop
else
remove_prop
then
;
: MSG-clearoldinfo (base dbref -- )
swap
$ifdef SLASHED_LISTS
over over
"#/i" strcat safeclear
$else
"/i" strcat safeclear
$endif
;
: MSG-oldinfo (base dbref -- infostr)
swap "/i" strcat getpropstr
;
: MSG-newinfo (base dbref -- infostr)
swap "#/i" strcat getpropstr
;
: convert-info (base dbref value -- )
3 pick 3 pick MSG-clearoldinfo
rot rot MSG-setinfo
;
: MSG-info (base dbref -- infostr)
$ifdef SLASHED_LISTS
over over MSG-newinfo
dup if rot rot pop pop exit then
pop over over MSG-oldinfo
dup if dup -4 rotate convert-info exit then
$else
over over MSG-oldinfo
dup if rot rot pop pop exit then
pop over over MSG-newinfo
dup if dup -4 rotate convert-info exit then
$endif
pop pop pop ""
;
: MSG-item (itemnum base dbref -- itemstr)
$ifndef SLASHED_LISTS
3 pick 3 pick "/" strcat 3 pick
LMGR-getelem
dup if
-4 rotate pop pop pop exit
else pop
then
$endif
LMGR-getelem
;
: MSG-setitem (itemstr itemnum base dbref -- )
$ifndef SLASHED_LISTS
swap "/" strcat swap
$endif
LMGR-putelem
;
: MSG-insitem (itemstr itemnum base dbref -- )
$ifndef SLASHED_LISTS
swap "/" strcat swap
$endif
1 -4 rotate LMGR-insertrange
;
: MSG-append (itemstr base dbref -- )
$ifndef SLASHED_LISTS
swap "/" strcat swap
$endif
over over LMGR-getcount 1 +
rot rot LMGR-putelem
;
: MSG-delitem (itemnum base dbref -- )
$ifndef SLASHED_LISTS
swap "/" strcat swap
$endif
1 -4 rotate LMGR-deleterange
;
PUBLIC MSG-destroy
PUBLIC MSG-create
PUBLIC MSG-count
PUBLIC MSG-info
PUBLIC MSG-setinfo
PUBLIC MSG-message
PUBLIC MSG-item
PUBLIC MSG-setitem
PUBLIC MSG-insitem
PUBLIC MSG-append
PUBLIC MSG-delitem
.
c
q
@register lib-mesg=lib/mesg
@register #me lib-mesg=tmp/prog1
@set $tmp/prog1=L
@set $tmp/prog1=V
@set $tmp/prog1=/_/de:A scroll containing a spell called lib-mesg
@set $tmp/prog1=/_defs/MSG-append:"$lib/mesg" match "MSG-append" call
@set $tmp/prog1=/_defs/MSG-count:"$lib/mesg" match "MSG-count" call
@set $tmp/prog1=/_defs/MSG-create:"$lib/mesg" match "MSG-create" call
@set $tmp/prog1=/_defs/MSG-delitem:"$lib/mesg" match "MSG-delitem" call
@set $tmp/prog1=/_defs/MSG-destroy:"$lib/mesg" match "MSG-destroy" call
@set $tmp/prog1=/_defs/MSG-info:"$lib/mesg" match "MSG-info" call
@set $tmp/prog1=/_defs/MSG-insitem:"$lib/mesg" match "MSG-insitem" call
@set $tmp/prog1=/_defs/MSG-item:"$lib/mesg" match "MSG-item" call
@set $tmp/prog1=/_defs/MSG-message:"$lib/mesg" match "MSG-message" call
@set $tmp/prog1=/_defs/MSG-setinfo:"$lib/mesg" match "MSG-setinfo" call
@set $tmp/prog1=/_defs/MSG-setitem:"$lib/mesg" match "MSG-setitem" call
@set $tmp/prog1=/_docs:@list $lib/mesg=1-50