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.
Entire forum
➜ MUSHclient
➜ General
➜ Trying to automate a skill with triggers
Trying to automate a skill with triggers
|
Posting of new messages is disabled at present.
Refresh page
Posted by
| Xandler
(52 posts) Bio
|
Date
| Thu 30 Jun 2022 04:40 PM (UTC) |
Message
| I have been struggling with this for what seems like weeks (I keep going back to it to see if I can get it to work)
I have no idea WHY this will not work (I don't get any error messages), it just will not fire when the conditions are met.
<triggers>
<trigger
enabled="y"
expand_variables="y"
group="kaioken"
keep_evaluating="y"
match="Gravity: Normal"
send_to="12"
sequence="100"
>
<send>if GetVariable("kaiokenlevel") == 0 and GetVariable("pki") >= 90 then
Send 'kaioken'
Send 'score'
else
if @pki <= 20 then
Send 'kaioken'
Send 'score'
end
end
end</send>
</trigger>
</triggers>
Did I structure this wrong? I initially used the @variable then switched but neither version worked. Again, I get no error messages, the first half will not fire when the conditions are met. | Top |
|
Posted by
| Fiendish
USA (2,533 posts) Bio
Global Moderator |
Date
| Reply #1 on Thu 30 Jun 2022 07:22 PM (UTC) |
Message
| If the trigger doesn't fire then the conditions are not met. What line do you expect it to fire on? |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Xandler
(52 posts) Bio
|
Date
| Reply #2 on Thu 30 Jun 2022 08:29 PM (UTC) Amended on Thu 30 Jun 2022 08:35 PM (UTC) by Xandler
|
Message
| Basically, I want it to fire off this:
if GetVariable("kaiokenlevel") == 0 and GetVariable("pki") >= 90 then
Send 'kaioken'
Send 'score'
Variables for kaiokenlevel which starts at 0 (So that should always be true) and when the the pki variable is at or above 90 it should fire kaioken, then score. I have actually looked in my variables window when both are true and it won't fire, however, I have tested with each variable individually and it works for the pki when that's above 90, but not kaiokenlevel when that's at 0 so I'm unsure what the issue with that variable is. The trigger I have to set up my capture of kaiokenlevel is working properly too as it captures the correct number in the variables window. | Top |
|
Posted by
| Fiendish
USA (2,533 posts) Bio
Global Moderator |
Date
| Reply #3 on Thu 30 Jun 2022 08:39 PM (UTC) Amended on Thu 30 Jun 2022 08:42 PM (UTC) by Fiendish
|
Message
| I mean what line from the game do you expect your trigger to match?
Quote: but not kaiokenlevel when that's at 0
Are you sure it's 0 and not "0"? Please show the code where you set your variables. |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #4 on Fri 01 Jul 2022 05:26 AM (UTC) Amended on Fri 01 Jul 2022 05:27 AM (UTC) by Nick Gammon
|
Message
|
Quote:
if GetVariable("kaiokenlevel") == 0 and GetVariable("pki") >= 90 then
Send 'kaioken'
Send 'score'
else
if @pki <= 20 then
Send 'kaioken'
Send 'score'
end
end
end
I indented it for you. There seems to be an "end" too many.
In any case you are inconsistent with your use of variables. Why use @pki and GetVariable("pki") in the same script?
An important point is that GetVariable("pki") returns a string and not a number, and in Lua strings are not converted into numbers, thus "100" would be considered less than "90", because 1 is less than 9, and in strings they are compared from left to right.
One thing to try there is to convert it to a number, eg.
if tonumber (GetVariable("kaiokenlevel")) == 0 and tonumber (GetVariable("pki")) >= 90 then
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Xandler
(52 posts) Bio
|
Date
| Reply #5 on Fri 01 Jul 2022 11:20 AM (UTC) Amended on Fri 01 Jul 2022 12:21 PM (UTC) by Xandler
|
Message
| I managed to figure it out with some trial and errors, I changed the code to the following:
if (@kaiokenlevel == 0 and @pki >= 90) then
Send 'kaioken'
Send 'score'
elseif (@kaiokenlevel > 0 and @pki <= 20) then
Send 'kaioken'
Send 'score'
SetVariable ("kaiokenlevel", "0")
end
That seems to have made it work, this thread can be closed now. Thanks for the input. I don't indent my code because it's easier for me to read (probably backwards to most of you) than it is when I do. Also, I used the @ and GetVariable in the same snippet as I was trying to do it off a previous trigger (not related to this) that I have that uses both (I didn't write it), was given to me via pastebin.
Either way, problem solved. | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #6 on Fri 01 Jul 2022 08:44 PM (UTC) |
Message
| Yes, that will also work, because when you use variables like that the contents are literally inserted into the code (without quotes) so numbers are still numbers. |
- 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.
9,457 views.
Posting of new messages is disabled at present.
Refresh page
top