Possible Bug Comparing String Values

  • #1, z OrlixFriday, 10. June 2016, 17:21 hodinky 9 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

    Bažant

    20 Posts


  • #2, z sebastianFriday, 10. June 2016, 18:10 hodinky 9 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...

    Kapitán

    2346 Posts

  • #3, z SimonSFriday, 10. June 2016, 18:20 hodinky 9 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.

    Kapitán

    1582 Posts

  • #4, z OrlixFriday, 10. June 2016, 18:25 hodinky 9 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

    Bažant

    20 Posts

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

    Kapitán

    2346 Posts

  • #6, z afrlmeFriday, 10. June 2016, 18:39 hodinky 9 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

    Imperátor

    7285 Posts

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

    Kapitán

    2346 Posts

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

    Bažant

    20 Posts