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 ➜ General ➜ How to make a table match enable a timer....

How to make a table match enable a timer....

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


Posted by Walton   (4 posts)  Bio
Date Fri 19 Jun 2009 09:21 PM (UTC)
Message

table = table or {}
if table["%1"] and not table["%2"] then
EnableTimer("timer",true)
end


The above format will work if I try to send a command rather than enable something...but how can I use a table match to enable another timer or trigger?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Fri 19 Jun 2009 10:20 PM (UTC)
Message
You want to enable a timer if something is in a table, and something else is not in it?

What you have should work. You may want to reset the timer to make it start from scratch again.

http://www.gammon.com.au/scripts/doc.php?function=ResetTimer

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Walton   (4 posts)  Bio
Date Reply #2 on Sat 20 Jun 2009 03:22 AM (UTC)
Message
You're right. That wasn't the problem..

In another part of the script I have the same thing with the variables reversed, and it does not work.

example here:

table = table or {}
if table["%2"] and not table["%1"] then
EnableTimer("timer",true)
end


Shouldn't the above work too?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Sat 20 Jun 2009 03:41 AM (UTC)
Message
Yes it should. I would point out that "table" is a Lua table of functions. See:

http://www.gammon.com.au/scripts/doc.php?general=lua_tables

Thus, using "table" as the name of your table might cause confusion.

In code like this:


if table["%2"] and not table["%1"] then
  EnableTimer("timer",true)
end


I would point in some debugging code.

For example:


print ("%%1 is '%1', %%2 is '%2'")
if table["%2"] and not table["%1"] then
  print ("enabling timer")
  EnableTimer("timer",true)
else
  print ("test failed")
end


This shows that you are executing the code in the first place, and whether the test fails or not.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Walton   (4 posts)  Bio
Date Reply #4 on Sat 20 Jun 2009 03:59 AM (UTC)
Message
Thanks for the response. I didn't actually use table as the name of the table, only in the example. The code did work on someone else's mushclient.....and our settings were set the same as far as I could tell. I'll see if I can get anything out of the debugging code but I'm confused as to what is happening.
Top

Posted by Walton   (4 posts)  Bio
Date Reply #5 on Sat 20 Jun 2009 04:13 AM (UTC)
Message
here's what the debugging code is telling me:

The %1 is correct, the %2 is correct... but it's still failing.

It fires only if the code reads ["%1"] before ["%2"].
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #6 on Sat 20 Jun 2009 05:37 AM (UTC)
Message
Well, do you ever clear out the items from the table?

- 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.


16,608 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.