Login / Registrieren
DE EN FR ES IT CZ
Zurück Nach oben

Possible Bug Comparing String Values

  • #1, by Orlix 10 years ago Zitieren
    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
  • #2, by sebastian 10 years ago Zitieren
    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...
  • #3, by SimonS 10 years ago Zitieren
    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.
  • #4, by Orlix 10 years ago Zitieren
    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
  • #5, by sebastian 10 years ago Zitieren
    If getObject("Values[SELECTED_ITEM_NAME] "):getStr(VValueString) == getObject("Values[ALL_BRAN1_NAME] "):getStr(VValueString) then
    ...
    else
    ...
    end
  • #6, by afrlme 10 years ago Zitieren
    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
  • #7, by sebastian 10 years ago Zitieren
    Afrlme got the shorter version. Use his masterpiece smile
  • #8, by Orlix 10 years ago Zitieren
    So nice, thank you all mates smile