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
➜ Creating an alias to toggle a trigger group on/off
Creating an alias to toggle a trigger group on/off
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Darcon
(26 posts) Bio
|
Date
| Fri 19 Oct 2012 04:32 AM (UTC) |
Message
| Hi, I am new to MushClient. I am also new to scripting. I am taking time to learn Lua on my own so I am just in the basics now.
Anyway what I am trying to do is create an alias that will toggle a trigger group from enabled to disabled or visa versa.
Here what I have so far. I created an alias called moneyrun and a variable called MoneyRun. I initially set the variable to 1.
The alias is set to send to script. In the send box:
EnableTriggerGroup ("Money Run", GetVariable("MoneyRun"))
if GetVariable("MoneyRun") == 1
then SetVariable("MoneyRun", "0");print("Money Run Enabled") else SetVariable("MoneyRun", "1");print("Money Run Disabled") end
When I initiate the alias, if the variable is set to 0, it will enable the group. When I do it again, it does not disable like it should. What am I doing wrong here? I appreciate any feedback. | Top |
|
Posted by
| Darcon
(26 posts) Bio
|
Date
| Reply #1 on Fri 19 Oct 2012 05:11 AM (UTC) |
Message
| I did end up getting the alias to work correctly. I simplified the code and now it works as I intended it to.
EnableTriggerGroup ("Money Run", MoneyRun)
if MoneyRun == 1
then MoneyRun = 0
print("Money Run Enabled")
else MoneyRun = 1
print("Money Run Disabled")
end
What I don't understand is that the variable doesn't change in the variable screen of mush client it remains 0 in either state. I don't know why it doesn't but since it seems to be doing what it should be then I don't really care.
If anyone has any input on this or a better way to accomplish this I would appreciate it. Thanks | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #2 on Fri 19 Oct 2012 05:35 AM (UTC) |
Message
| |
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #3 on Fri 19 Oct 2012 05:36 AM (UTC) |
Message
|
if GetVariable("MoneyRun") == 1
Client variables are always strings. Thus you should have tested for:
if GetVariable("MoneyRun") == "1"
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Darcon
(26 posts) Bio
|
Date
| Reply #4 on Fri 19 Oct 2012 07:45 AM (UTC) |
Message
| |
Posted by
| Darcon
(26 posts) Bio
|
Date
| Reply #5 on Fri 19 Oct 2012 08:14 AM (UTC) |
Message
| Ok so now that I know the difference between a script variable and a client variable I rewrote the code once again.
EnableTriggerGroup ("Money Run", GetVariable("MoneyRun"))
if GetVariable("MoneyRun") == "1"
then SetVariable("MoneyRun", "0")
print("Money Run Enabled")
else SetVariable("MoneyRun", "1")
print("Money Run Disabled")
end
As expected, it worked perfectly and now the client variable is actually reflecting the state of the variable. Thank again for your help Nick. | 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.
18,335 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top