Compare a string variable of an object.

Get help using Construct 2

Post » Tue Dec 03, 2013 12:04 am

I have a string variable of an object, and call it 'V', and set it's value to 'Correct'

I then try the line 'Object : V is not equal to False'

It doesn't trigger.

It should trigger, because 'Correct' is not equal to 'False'. This works fine with numbers, but it's not working with strings. Am I doing something wrong?
B
26
S
6
G
4
Posts: 456
Reputation: 5,853

Post » Tue Dec 03, 2013 12:07 am

My brain just exploded. Don't use variables that are called Yes, No, Correct. When you set them to True/False it's just highly confusing. What does 'V is not equal to False' mean? V is not equal to the string "False"? And what does "Correct" is not equal to "False" mean?plinkie2013-12-03 00:08:52
B
47
S
17
G
81
Posts: 2,221
Reputation: 48,089

Post » Tue Dec 03, 2013 12:20 am

@plinkie is right

however you if for some reason you do because maybe there is some error code that passes with it?.

so don't forget your qoutes.

Object.setVariable("V", "false")
In the properties list on the side. Don't use qoutes as that automatically handles data types. But in all expression lines make sure you use qoutes.

so
Property bar
Object.V = false

Action
object.setVaribale V = "false:


So to check it then do
Object.V != "false". this would check string object of V against string

where as
Object.V != false. is comparing a STRING against a BOOLEAN value as false is actually system value.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,038

Post » Tue Dec 03, 2013 12:34 am

I wasn't actually using 'Correct' and 'False', I was just using those here as an example.

It turned out to be an unrelated error anyway, but thanks for the heads-up about not using quotes when setting the value in the editor - that was causing errors in my example program that I'd thrown together to try to recreate this problem.

As it turns out, it was working fine but another section further down my program was making it look like it wasn't working.

Thanks for your replies :)farflamex2013-12-03 01:45:01
B
26
S
6
G
4
Posts: 456
Reputation: 5,853


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 7 guests