-
Notifications
You must be signed in to change notification settings - Fork 0
/
SCRIPTS
307 lines (251 loc) · 6.14 KB
/
SCRIPTS
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
--------------------------------------------------------------------------------
001 Loop through room 1 to 1000 and change the color of rooms with the
static (16) flag.
--------------------------------------------------------------------------------
#loop 1 1000 vnum
{
#map goto $vnum;
#map get roomflags result;
#if {$result & 16}
{
#map set roomcolor <168>
}
{
#map set roomcolor <178>
}
}
--------------------------------------------------------------------------------
002 Capture session information.
--------------------------------------------------------------------------------
#action {^#SESSION '%1' CONNECTED TO '%2' PORT '%3'}
{
#var session %1;
#var address %2;
#var port %3
}
--------------------------------------------------------------------------------
003 Capture system information. #script stores the output as a list,
hence the need to convert it into a normal variable.
--------------------------------------------------------------------------------
#script {dir} {pwd}
#var dir $dir[1]
#script {home} {echo $HOME}
#var home $home[1]
--------------------------------------------------------------------------------
004 Automatically reconnect on disconnect.
--------------------------------------------------------------------------------
#event {SESSION CONNECTED}
{
#event {SESSION DISCONNECTED}
{
#gts #delay 5 {#session %0 %1 %3}
}
}
--------------------------------------------------------------------------------
005 Execute a random social at random time intervals.
--------------------------------------------------------------------------------
#tick {randomsocial}
{
#delay {1d200-5}
{
#switch {1d3}
{
#case {1} {cheer}
#case {2} {greet all}
#case {3} {smile}
}
}
}
{200}
--------------------------------------------------------------------------------
006 Maintain a friendlist.
--------------------------------------------------------------------------------
#variable {friendlist}
{
{1} {bubba}
{2} {pamela}
{3} {cookie}
{4} {harry potter}
}
#function isfriend
{
#format name %l {%0};
#list friendlist fnd {$name} result
}
#act {%1 follows you.}
{
#if {@isfriend{%1}}
{
group %1
};
#else
{
unfollow %1
}
}
#alias {addfriend}
{
#format name %l {%0};
#list friendlist ins -1 $name;
#showme $name has been added to your friendlist.
}
#alias {delfriend}
{
#format name %l {%0};
#if {@isfriend{$name}}
{
#list friendlist del @isfriend{$name};
#showme $name has been deleted from your friendlist.
};
#else
{
#showme $name is not on your friendlist.
}
}
--------------------------------------------------------------------------------
007 Append a goto to your current room when saving a map
--------------------------------------------------------------------------------
#alias {savemap}
{
#map write %0;
#map get roomvnum room;
#system echo '#map goto $room' >> %0
}
--------------------------------------------------------------------------------
008 Log all text to a file with a timestamp with decisecond precision.
--------------------------------------------------------------------------------
#function {timestamp}
{
#format utime {%U};
#format result {%t.%m} {%Y-%m-%d %H:%M:%S} {$utime % 1000000 / 100000}
}
#event {RECEIVED LINE}
{
#line log mylog.txt {<178>@timestamp{} \};
#line log mylog.txt
}
--------------------------------------------------------------------------------
009 Old school tick support.
--------------------------------------------------------------------------------
#tick {oldtick}
{
#delay 50 #showme #10 SECONDS TO TICK!!;
#showme #TICK!!!
}
{60}
--------------------------------------------------------------------------------
010 Execute speedwalks with .
--------------------------------------------------------------------------------
#alias {.%0}
{
#var cnt {};
#parse {%0} {char}
{
#if {"$char" >= "0" && "$char" <= "9"}
{
#var cnt $cnt$char
};
#elseif {"$cnt" == ""}
{
#send $char
};
#else
{
#$cnt #send $char;
#var cnt {}
}
}
}
--------------------------------------------------------------------------------
011 Targetting script
--------------------------------------------------------------------------------
#var targets {}
#alias {target}
{
#if {"%0" == ""}
{
#showme {Current targets: $targets[]}
};
#elseif {$targets[%0]}
{
#unvar targets[%0];
#showme Target '%0' removed.
};
#else
{
#var targets[%0] {};
#showme Target '%0' added.
}
}
#act {%1 arrives}
{
#if {$targets[%1]} {kill %1}
}
#act {%1 is standing here}
{
#if {$targets[%1]} {kill %1}
}
#action {%1 is dead! R.I.P.}
{
#if {$targets[%1]} {target %1}
}
--------------------------------------------------------------------------------
014 Show xterm 256 colors.
--------------------------------------------------------------------------------
#var temp {}
#foreach {0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15} {var1}
{
#showme {$var1 \e[38;5;${var1}m}
}
#foreach {a;b;c;d;e;f} {var1}
{
#foreach {a;b;c;d;e;f} {var2}
{
#foreach {a;b;c;d;e;f} {var3}
{
#var temp {$temp <$var1$var2$var3><<888>$var1$var2$var3>}
};
#showme $temp;
#var temp {}
}
}
#loop 0 23 cnt
{
#format temp {$temp <g%+02s><<888>g%+02s} {$cnt} {$cnt};
}
#showme $temp
--------------------------------------------------------------------------------
015 Draw a health bar.
--------------------------------------------------------------------------------
#alias {hpbar}
{
#math {hp_percent}{100 * %1 / %2};
#math {hpbars1} {$hp_percent / 5};
#math {hpbars2} {20 - $hpbars1};
#format {hpbar} {<011>%+${hpbars1}s<099><000>%+${hpbars2}s<099> };
#showme [$hpbar]
}
#alias {test}
{
hpbar 30 100
}
--------------------------------------------------------------------------------
016 Syntax: sleep <seconds to delay> {commands}
If there is already a pending sleep the delay will be stacked.
--------------------------------------------------------------------------------
#var sleeptime 0
#var sleepcurr 0
#alias {sleep %1 %2}
{
#format sleeptime %U;
#if {$sleeptime > $sleepcurr}
{
#math sleepcurr $sleeptime + (%1) * 1000000;
#delay {%1} %2;
};
#else
{
#math sleepcurr $sleepcurr + (%1) * 1000000;
#delay {($sleepcurr - $sleeptime) / 1000000.000} %2
}
}