-
Notifications
You must be signed in to change notification settings - Fork 15
/
Slow_speedwalk.xml
270 lines (197 loc) · 6.73 KB
/
Slow_speedwalk.xml
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
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient
[
<!ENTITY speedwalk_alias "!*" >
<!ENTITY pause_speedwalk_alias "pause speedwalk" >
<!ENTITY resume_speedwalk_alias "resume speedwalk" >
<!ENTITY abort_speedwalk_alias "abort speedwalk" >
<!ENTITY help_speedwalk_alias "help speedwalk" >
<!ENTITY timeout_secs "10" >
<!ENTITY delay_secs "0.5" >
<!ENTITY exits_trigger
"^((?P<exits>\\[Exits\\: .+\\])|(.*)Alas, you cannot go that way\\.)$" >
]>
<!-- Saved on Monday, October 24, 2005, 7:21 AM -->
<!-- MuClient version 3.67 -->
<!-- Plugin "Slow_speedwalk" generated by Plugin Wizard -->
<!--
Customise the entities above to modify for the exact MUD output you get.
speedwalk_alias - the alias you want to invoke a speedwalk (eg. !*)
pause_speedwalk_alias - the alias you type to pause a speedwalk (eg. 'pause speedwalk')
resume_speedwalk_alias - the alias you type to resume a speedwalk (eg. 'resume speedwalk')
abort_speedwalk_alias - the alias you type to abort a speedwalk (eg. 'abort speedwalk')
timeout_secs - the time to wait for a new room "exits" line to arrive (eg. 10)
delay_secs - the time to wait after each speedwalk succeeds, before doing another one (eg. 0.5)
exits_trigger - this detects either that we have gone to a new room, or we can't move
In the exits_trigger any backslashes have to be doubled, as the first one is processed by Lua,
so we need two to reach the regular expression parser.
The named wildcard portion (?P<exits> ... ) is designed to be tested in the script
so that if it is not empty we know we hit an exits line, rather than "you cannot go that
way". eg. [Exits: North South]
-->
<!-- Version 2 uses wait.lua for extra compactness -->
<muclient>
<plugin
name="Slow_speedwalk"
author="Nick Gammon"
id="56c9c5763d0c9c6ccf1e5b60"
language="Lua"
purpose="Speedwalks, waiting for each room to arrive"
date_written="2005-10-24 07:16:09"
date_modified="2008-06-4 06:56:09"
requires="3.67"
version="2.0"
>
<description trim="y">
Usage
-----
! <speedwalk> - walks in that direction, eg. ! 5n 3w
&pause_speedwalk_alias; - pauses the speedwalk so you can do something else
&resume_speedwalk_alias; - resumes a paused speedwalk
&abort_speedwalk_alias; - aborts the current speedwalk
&help_speedwalk_alias; - this message
The speedwalk waits for the appropriate "Exits" message to appear so it knows it has reached a new room.
If it receives a "cannot go that way" message, the speedwalk is aborted.
If an "exits" message does not appear within 10 seconds the speedwalk is aborted.
</description>
</plugin>
<!-- Aliases -->
<aliases>
<alias
match="&speedwalk_alias;"
enabled="y"
script="func_handle_speedwalk"
>
</alias>
<alias
match="&pause_speedwalk_alias;"
enabled="y"
script="func_pause_speedwalk"
>
</alias>
<alias
match="&resume_speedwalk_alias;"
enabled="y"
script="func_resume_speedwalk"
>
</alias>
<alias
match="&abort_speedwalk_alias;"
enabled="y"
script="func_abort_speedwalk"
>
</alias>
<alias
match="&help_speedwalk_alias;"
enabled="y"
script="func_help_speedwalk"
>
</alias>
</aliases>
<!-- Script -->
<script>
require "tprint"
require "wait"
require "getlines"
-- main function called when you type a speedwalk
function func_handle_speedwalk (name, line, wildcards)
wait.make (function () --- coroutine below here
sw = EvaluateSpeedwalk (wildcards [1])
if string.sub (sw, 1, 1) == "*" then
ColourNote ("white", "red", string.sub (sw, 2))
return
end -- if
pause_speedwalk = false -- no pause yet
abort_speedwalk = false -- no abort yet
speedwalk_thread = coroutine.running () -- remember this thread
-- iterate the speedwalk string, line by line, sending each line to the MUD
for walk_line in getlines (sw) do
if string.match (walk_line, "^%s*$") then
break
end -- empty line - probably end of speedwalk
-- see if pausing wanted (global variable set)
if pause_speedwalk then
ColourNote ("white", "green", "Speedwalk paused.")
ret = coroutine.yield ()
if ret == "abort" then
ColourNote ("black", "yellow", "Speedwalk abandoned.")
speedwalk_thread = nil
return
end -- abort speedwalk wanted
ColourNote ("white", "green", "Speedwalk resumed.")
pause_speedwalk = false
end -- if
-- see if aborting wanted
if abort_speedwalk then
ColourNote ("black", "yellow", "Speedwalk abandoned.")
speedwalk_thread = nil
return
end -- if
-- send the speedwalk
Send (walk_line)
-- now wait for an appropriate response
line, wildcards = wait.regexp ("&exits_trigger;", &timeout_secs;)
-- check for timeout
if not line then
ColourNote ("white", "red", "Speedwalk timed-out")
speedwalk_thread = nil
return -- give up
end -- if
-- check we didn't get told it was impossible
if wildcards.exits == "" then
ColourNote ("white", "red", "Speedwalk cancelled")
speedwalk_thread = nil
return -- give up
end -- if
-- pause before doing another if wanted
if &delay_secs; > 0 then
wait.time (&delay_secs;)
end -- if pause wanted
end -- of iterating through each speedwalk line
-- all done!
ColourNote ("white", "blue", "Speedwalk done.")
speedwalk_thread = nil
end) -- end of coroutine
end -- function func_handle_speedwalk
-- called to pause the current speedwalk
function func_pause_speedwalk ()
if speedwalk_thread then
if pause_speedwalk then
ColourNote ("black", "yellow", "The speedwalk is already paused.")
else
pause_speedwalk = true
end
else
ColourNote ("black", "yellow", "No speedwalk is active.")
end
end -- func_pause_speedwalk
-- called to resume after a pause
function func_resume_speedwalk ()
if speedwalk_thread then
if pause_speedwalk then
assert (coroutine.resume (speedwalk_thread, "resume"))
else
ColourNote ("black", "yellow", "The speedwalk is not paused.")
end
else
ColourNote ("black", "yellow", "No speedwalk is active.")
end
end -- func_resume_speedwalk
-- called to abort the speedwalk
function func_abort_speedwalk ()
if speedwalk_thread then
if pause_speedwalk then
assert (coroutine.resume (speedwalk_thread, "abort"))
else
abort_speedwalk = true
end
else
ColourNote ("black", "yellow", "No speedwalk is active.")
end
end -- func_abort_speedwalk
function func_help_speedwalk ()
world.Note (world.GetPluginInfo (world.GetPluginID (), 3))
end
DoAfterSpecial (1, 'ColourNote ("white", "green", "Slow speedwalk plugin installed.")', 12);
</script>
</muclient>