Possible Bug Comparing String Values

  • #1, by OrlixFriday, 10. June 2016, 17:21 8 years ago
    Hi,

    I think i´ve found a bug when comparing two values (Strings) using action part "If Value".
    Comparing two different values, always return´s TRUE.

    What am i doing?

    1 - I have an action in an item, called by other action in a scene object. In the beginning of the item action, i have this action part "If Value" that compares a value from item (with the item name) with a value from an interface. (ss1.png)

    2 - I have inserted 2 script just to debug what values came to this point. One before the "if value" condition, just to print both string values i will compare. And the other just after the "if value" condition printing the word "ENTERED" to confirm that even with different values he enters in the condition. (ss2.png)

    3 - Run the action and look at the log an analyse those prints. (ss3.png)

    After those steps i´m able to conclude that two different string values are being compared and they return true. Is this a bug or what am i escaping here?shock


    Best regards,
    Orlix

    Newbie

    20 Posts


  • #2, by sebastianFriday, 10. June 2016, 18:10 8 years ago
    Hmm. What values do you have saved in them (the value, not the string) ?

    I would guess you dont check if ALL_BRAN1_NAME is equal SELECTED_ITEM_NAME.
    You check if ALL_BRAN1_NAME is equal 100000...

    Thread Captain

    2346 Posts

  • #3, by SimonSFriday, 10. June 2016, 18:20 8 years ago
    Hi, these action parts do not compare the strings, only the ints VValueInt. If you want to compare strings you need to compare them in lua and then set a value and "if" on that.

    Thread Captain

    1580 Posts

  • #4, by OrlixFriday, 10. June 2016, 18:25 8 years ago
    Ohh so that´s the problem, i thought that this action could compares String to String and int to int.

    I´m not setting an int value for that, just simply try to compare strings.

    Is there a way to compare strings?

    Thanks

    Newbie

    20 Posts

  • #5, by sebastianFriday, 10. June 2016, 18:38 8 years ago
    If getObject("Values[SELECTED_ITEM_NAME] "):getStr(VValueString) == getObject("Values[ALL_BRAN1_NAME] "):getStr(VValueString) then
    ...
    else
    ...
    end

    Thread Captain

    2346 Posts

  • #6, by afrlmeFriday, 10. June 2016, 18:39 8 years ago
    Nope as Simon says (razz) the in-editor version only compares the integer values. If you want to return true or false in the editor then you could create a condition that you update in an execute a script action prior to the if query. In the execute a script action you could add something along the lines of this...
    if Values["value1"].ValueString == Values["value2"].ValueString then
    Conditions["cond1"].ConditionValue = true
    else
     Conditions["cond1"].ConditionValue = false
    end
    

    ... technically you don't have to type ValueString as .String is also valid in shorthand but sometimes only using .Int or .String returns a warning in the log file.

    * edit: or you can use Sebastian.204's getObject scripting method.

    @ Sebastian.204: you beat me to the punch. grin

    Imperator

    7278 Posts

  • #7, by sebastianFriday, 10. June 2016, 18:42 8 years ago
    Afrlme got the shorter version. Use his masterpiece smile

    Thread Captain

    2346 Posts

  • #8, by OrlixFriday, 10. June 2016, 19:19 8 years ago
    So nice, thank you all mates smile

    Newbie

    20 Posts