Compare a string variable of an object.

0 favourites
  • 4 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • 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?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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?

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

  • 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 :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)