Page 1 of 1

Help: An Off Issue

Posted: Tue May 06, 2014 2:00 pm
by icesteruk
Hey, I'll go straight to it.. Can someone please explain to me why these two are the same thing but both give different outcomes?

if matches[4] ~= "Scent" then

if not matches[4] == "Scent" then

One day one will work and the other doesn't and the next both will work.. I'm at a complete lost as to whats happening!..

Which is the correct way to do the above ^

Re: Help: An Off Issue

Posted: Tue May 06, 2014 2:05 pm
by keneanung
the second version can be translated as

if (not matches[4]) == "Scent" then

which probably not what you want. Version 1 is the correct one, though you could write it as

if not (matches[4]=="Scent") then

as well.

Re: Help: An Off Issue

Posted: Tue May 06, 2014 2:06 pm
by icesteruk
I had it as if not (matches[4] == "scent") then .. that didnt work .. lol just spent a hour going through everything and the only one that does seem to work is.. if matches[4] ~= "Scent" then .. even tho yesterday that didnt work :/

Re: Help: An Off Issue

Posted: Tue May 06, 2014 2:10 pm
by phasma
You're basically trying to evaluate a boolean against a string. So your second example is basically saying (assuming matches[4] has a value), if false == "Scent" then ... end.

Re: Help: An Off Issue

Posted: Tue May 06, 2014 2:15 pm
by keneanung
Also remember "scent" and "Scent" are different things.

Re: Help: An Off Issue

Posted: Tue May 06, 2014 2:24 pm
by icesteruk
I was using Scent ..

but still doesn't answer why if not matches[2] == "Scent" is different from if matches[2] ~= "Scent" i would have thought the if not would be better :/

Re: Help: An Off Issue

Posted: Tue May 06, 2014 2:33 pm
by keneanung
It does answer... Read feteaera's and my answer again...

not matches[4] == "Scent equals (not matches[4]) == "Scent" which is false == "Scent"

ETA: and "~=" is usually the easier understood version of "not equal" anyways....

Re: Help: An Off Issue

Posted: Fri May 09, 2014 12:00 am
by SlySven
Unless you're a C/C++ coder who keeps trying to use "!=". :geek: