Gammon Forum
Entire forum
MUSHclient
Suggestions
wait.lua error messages
It is now over 60 days since the last post. This thread is closed.
  Refresh page
Posted by
| Fiendish
USA (2,514 posts) bio
Global Moderator |
Date
| Sun 30 Sep 2012 05:46 AM (UTC) Amended on Sun 30 Sep 2012 06:39 AM (UTC) by Fiendish
|
Message
| Because assertion errors are big and scary (and don't direct the uneducated user to a solution), I'm considering doing the following in my distribution of wait.lua:
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")
+ local errors = {}
+ if GetOption("enable_timers") ~= 1 then
+ table.insert(errors, "TIMERS")
+ end
+ if GetOption("enable_triggers") ~= 1 then
+ table.insert(errors, "TRIGGERS")
+ end
+ 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 -1
+ end
coroutine.wrap (f) () -- make coroutine, resume it
+ return 0
end -- make
What do you think? |
https://github.com/fiendish/aardwolfclientpackage | top |
|
Posted by
| Nick Gammon
Australia (22,982 posts) bio
Forum Administrator |
Date
| Reply #1 on Sun 30 Sep 2012 06:20 AM (UTC) |
Message
| What is the return for? For checking somewhere else? |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| Nick Gammon
Australia (22,982 posts) bio
Forum Administrator |
Date
| Reply #2 on Sun 30 Sep 2012 06:26 AM (UTC) |
Message
| How about returning nil on an error and true on OK, like other similar functions? |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| Fiendish
USA (2,514 posts) bio
Global Moderator |
Date
| Reply #3 on Sun 30 Sep 2012 06:38 AM (UTC) |
Message
|
Nick Gammon said:
What is the return for? For checking somewhere else?
Yes.
Nick Gammon said:
How about returning nil on an error and true on OK, like other similar functions?
That would also work. |
https://github.com/fiendish/aardwolfclientpackage | top |
|
Posted by
| Nick Gammon
Australia (22,982 posts) bio
Forum Administrator |
Date
| Reply #4 on Sun 30 Sep 2012 06:39 AM (UTC) |
Message
| I like it. Incorporated in version 4.84 along with a few other fixes. Bad return will be nil, good return will be true. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
11,271 views.
It is now over 60 days since the last post. This thread is closed.
  Refresh page
top
Quick links:
MUSHclient.
MUSHclient help.
Forum shortcuts.
Posting templates.
Lua modules.
Lua documentation.
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.