Skip to content

Commit

Permalink
Improved wait.lua to give more friendly message if triggers/timers di…
Browse files Browse the repository at this point in the history
…sabled
  • Loading branch information
nickgammon committed Sep 30, 2012
1 parent ad4a0cb commit 48506a7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion install/readme.txt
@@ -1,7 +1,7 @@
MUSHclient version 4.84
=======================

Tuesday, 29th September 2012
Sunday, 30th September 2012

Author: Nick Gammon
Web support: http://www.gammon.com.au/forum/
Expand Down
22 changes: 20 additions & 2 deletions lua/wait.lua
Expand Up @@ -156,7 +156,25 @@ end -- function match
-- ----------------------------------------------------------
function make (f)
assert (type (f) == "function", "wait.make requires a function")
assert (GetOption ("enable_timers") == 1, "Timers not enabled")
assert (GetOption ("enable_triggers") == 1, "Triggers not enabled")
-- More friendly failure, suggested by Fiendish
local errors = {}
if GetOption ("enable_timers") ~= 1 then
table.insert (errors, "TIMERS")
end -- if timers disabled
if GetOption ("enable_triggers") ~= 1 then
table.insert (errors, "TRIGGERS")
end -- if triggers disabled
if #errors ~= 0 then
ColourNote("white", "red",
"One of your scripts (in '" ..
(GetPluginInfo(GetPluginID(), 1) or "World") ..
"') just did something that requires " ..
table.concat (errors, " and ") ..
" to be enabled, but they aren't. " ..
"Please check your configuration settings.")
return nil, "Trigger/Timers not enabled" -- bad return
end -- if have errors
coroutine.wrap (f) () -- make coroutine, resume it
return true -- good return
end -- make

0 comments on commit 48506a7

Please sign in to comment.