[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  IF OR THEN
Home  |  Users  |  Search  |  FAQ
Register forum user name
Forgotten password?


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

Posted by Magellan   (13 posts)  [Biography] bio
Date Mon 31 Jul 2017 04:18 AM (UTC)
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.
[Go to top] top

Posted by Nick Gammon   Australia  (21,674 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Mon 31 Jul 2017 08:29 PM (UTC)
Normally you compare without the quotes.

 if rX <= 45 or rY <= 45 then

What are rX and rY? Can you post the trigger please?

Template:copying 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
[Go to top] top

Posted by Magellan   (13 posts)  [Biography] bio
Date Reply #2 on Mon 14 Aug 2017 12:42 AM (UTC)
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")
Note ("Out of Range")

[Go to top] top

Posted by GaidinBDJ   (4 posts)  [Biography] bio
Date Reply #3 on Sat 02 Sep 2017 09:16 AM (UTC)
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")
Note ("Out of Range")

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.
[Go to top] 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.


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

Go to topic:           Search the forum

[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]