Help: An Off Issue

Post Reply
icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Help: An Off Issue

Post 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 ^

User avatar
keneanung
Site Admin
Posts: 94
Joined: Mon Mar 21, 2011 9:36 am
Discord: keneanung#2803

Re: Help: An Off Issue

Post 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.

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: Help: An Off Issue

Post 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 :/

phasma
Posts: 191
Joined: Sat Aug 03, 2013 7:00 pm
Discord: phasma#4694

Re: Help: An Off Issue

Post 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.

User avatar
keneanung
Site Admin
Posts: 94
Joined: Mon Mar 21, 2011 9:36 am
Discord: keneanung#2803

Re: Help: An Off Issue

Post by keneanung »

Also remember "scent" and "Scent" are different things.

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: Help: An Off Issue

Post 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 :/

User avatar
keneanung
Site Admin
Posts: 94
Joined: Mon Mar 21, 2011 9:36 am
Discord: keneanung#2803

Re: Help: An Off Issue

Post 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....

User avatar
SlySven
Posts: 1019
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Help: An Off Issue

Post by SlySven »

Unless you're a C/C++ coder who keeps trying to use "!=". :geek:

Post Reply