-
Notifications
You must be signed in to change notification settings - Fork 15
/
Command_Throttler.xml
171 lines (126 loc) · 2.95 KB
/
Command_Throttler.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
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Thursday, May 01, 2008, 9:38 AM -->
<!-- MuClient version 4.23 -->
<!-- Plugin "Command_Throttler" generated by Plugin Wizard -->
<muclient>
<plugin
name="Command_Throttler"
author="Nick Gammon"
id="40b23d22e34074ddefa98f09"
language="Lua"
purpose="Sends commands to the MUD gradually"
date_written="2008-05-01 09:34:22"
requires="4.18"
version="1.0"
>
<description trim="y">
<![CDATA[
"Throttles" your output to an acceptable rate.
Aliases:
show_queue --> display outstanding queue
empty_queue --> discard entire queue
Command_Throttler:help --> this help
]]>
</description>
</plugin>
<!-- Aliases -->
<aliases>
<alias
match="empty_queue"
enabled="y"
send_to="12"
sequence="100"
>
<send>
ColourNote ("gray", "", "Deleted " .. #queue .. " outstanding item(s) from the queue.")
queue = {} -- queue is now empty
</send>
</alias>
<alias
match="show_queue"
enabled="y"
send_to="12"
sequence="100"
>
<send>
if #queue == 0 then
ColourNote ("gray", "", "Pending command queue is empty")
return
end -- if
ColourNote ("gray", "", "Command queue:")
for k, v in ipairs (queue) do
ColourNote ("gray", "", k .. ": " .. v)
end -- for
ColourNote ("gray", "", #queue .. " outstanding item(s) in the command queue.")
</send>
</alias>
</aliases>
<!-- Timers -->
<timers>
<timer
enabled="y"
second="0.20"
offset_second="0.00"
send_to="12"
>
<send>
-- no queued commands? just exit
if next (queue) == nil then
return
end -- if empty
-- send the earliest item
send_now = true -- don't requeue it
Send (table.remove (queue, 1))
send_now = false -- queue if not from this plugin
</send>
</timer>
</timers>
<!-- Script -->
<script>
<![CDATA[
require "getlines"
queue = {}
send_now = false
function OnPluginInstall ()
if GetOption ("enable_timers") ~= 1 then
ColourNote ("white", "red", "Timers not enabled - commands will not be sent")
end -- if timers not enabled
if GetGlobalOption ("TimerInterval") ~= 0 then
ColourNote ("white", "red",
[[
Please go to the File menu -> Global Preferences Timers (Ctrl+Alt+G),
navigate to the Timers tab, and set the value for "Timer Interval" to be zero,
in order for this plugin to work correctly.
]])
end -- if timer interval not zero
end -- function OnPluginInstall
function OnPluginSend (s)
if send_now then
return true -- yes we can send it
end -- if sending from within the plugin
-- queue the command - broken into individual lines
for line in getlines (s) do
table.insert (queue, line)
end -- for loop
return false
end -- function OnPluginSend
]]>
</script>
<!-- Plugin help -->
<aliases>
<alias
script="OnHelp"
match="Command_Throttler:help"
enabled="y"
>
</alias>
</aliases>
<script>
<![CDATA[
function OnHelp ()
world.Note (world.GetPluginInfo (world.GetPluginID (), 3))
end
]]>
</script>
</muclient>