Help: An Off Issue

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

Help: An Off Issue

Post by icesteruk » Tue May 06, 2014 2:00 pm

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 » Tue May 06, 2014 2:05 pm

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 » Tue May 06, 2014 2:06 pm

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

fetaera
Posts: 191
Joined: Sat Aug 03, 2013 7:00 pm

Re: Help: An Off Issue

Post by fetaera » Tue May 06, 2014 2:10 pm

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 » Tue May 06, 2014 2:15 pm

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 » Tue May 06, 2014 2:24 pm

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 » Tue May 06, 2014 2:33 pm

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: 927
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Help: An Off Issue

Post by SlySven » Fri May 09, 2014 12:00 am

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

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests