Skip to content

Commit 48506a7

Browse files
committed
Improved wait.lua to give more friendly message if triggers/timers disabled
1 parent ad4a0cb commit 48506a7

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

install/readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
MUSHclient version 4.84
22
=======================
33

4-
Tuesday, 29th September 2012
4+
Sunday, 30th September 2012
55

66
Author: Nick Gammon
77
Web support: http://www.gammon.com.au/forum/

lua/wait.lua

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,25 @@ end -- function match
156156
-- ----------------------------------------------------------
157157
function make (f)
158158
assert (type (f) == "function", "wait.make requires a function")
159-
assert (GetOption ("enable_timers") == 1, "Timers not enabled")
160-
assert (GetOption ("enable_triggers") == 1, "Triggers not enabled")
159+
160+
-- More friendly failure, suggested by Fiendish
161+
local errors = {}
162+
if GetOption ("enable_timers") ~= 1 then
163+
table.insert (errors, "TIMERS")
164+
end -- if timers disabled
165+
if GetOption ("enable_triggers") ~= 1 then
166+
table.insert (errors, "TRIGGERS")
167+
end -- if triggers disabled
168+
if #errors ~= 0 then
169+
ColourNote("white", "red",
170+
"One of your scripts (in '" ..
171+
(GetPluginInfo(GetPluginID(), 1) or "World") ..
172+
"') just did something that requires " ..
173+
table.concat (errors, " and ") ..
174+
" to be enabled, but they aren't. " ..
175+
"Please check your configuration settings.")
176+
return nil, "Trigger/Timers not enabled" -- bad return
177+
end -- if have errors
161178
coroutine.wrap (f) () -- make coroutine, resume it
179+
return true -- good return
162180
end -- make

0 commit comments

Comments
 (0)