Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Suggestions ➜ wait.lua error messages

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,558 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  (23,173 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  (23,173 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,558 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  (23,173 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.


15,563 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.