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
➜ IF OR THEN
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Magellan
(15 posts) Bio
|
Date
| Mon 31 Jul 2017 04:18 AM (UTC) |
Message
| just trying to figure out if i have done this right or not. i am trying to have a trigger evaluate between two variables, if either are true, i want it to activate.
if (rX) <= "45" or (rY) <= "45" then
this line works if the first is true, but doesn't seem to work on the second. any suggestions? (also sorry if this is on the forum somewhere, i spent some time searching and couldn't find a relevant answer. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Mon 31 Jul 2017 08:29 PM (UTC) |
Message
| Normally you compare without the quotes.
if rX <= 45 or rY <= 45 then
What are rX and rY? Can you post the trigger please?
 |
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.
|
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Magellan
(15 posts) Bio
|
Date
| Reply #2 on Mon 14 Aug 2017 12:42 AM (UTC) |
Message
| i got it to work using AND which now that i've slept makes sense. at the time it didn't. but basically i'm tracking how far from a waypoint i am so it gives me a warning when i've traveled too far from it.
rX = GetVariable ("rX")
rY = GetVariable ("rY")
if (rX) <= "50" and (rY) <= "50" then
Note ("ok")
else
Note ("Out of Range")
end
| Top |
|
Posted by
| GaidinBDJ
(4 posts) Bio
|
Date
| Reply #3 on Sat 02 Sep 2017 09:16 AM (UTC) |
Message
| It looks like you're trying to compare them as numbers. When you use GetVariable, it returns a string (i.e. it looks like text rather than a number).
It looks like you're using Lua, so:
rX = tonumber(GetVariable ("rX"))
rY = tonumber(GetVariable ("rY"))
if rX <= 50 and rY <= 50 then
Note ("ok")
else
Note ("Out of Range")
end
The tonumber() bits were added, and the quotes were removed from the numbers in the if..then part. The quotes made "50" also look like text rather than a number and you don't want to generally compare a string like that unless you're looking for equal to/not equal to. | 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.
14,900 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top