Rule Bug.

Omegas7Omegas7 Member Posts: 37
edited November -1 in Tech Support
variable = 5

RULE: variable higher than 4
.......... variable = 4
otherwise
.......... move down
end

------

Output: Variable sets to 4 and then moves down.

It shouldn't move down because variable is higher than 4 (being 5).
Since it is higher than 4, it will set itself to 4.
BUT, the otherwise would be executed because now the variable isn't higher than 4!

...

Comments

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Well now that the variable is 4 and not greater than 4, the condition of the rule is false, so it executes the otherwise.

    Now if you just wanted to set any number greater than 4 for that variable, then use the ≥. That will set the variable to 4, and the condition will still be true and the otherwise won't be activated.

    However, any future changes to that variable(attribute) that make it ≥ 4, won't reactivate the TRUE behaviors to set the variable to 4 since it will still be true.
  • Omegas7Omegas7 Member Posts: 37
    That was an example, check this one:

    variable = 5

    RULE: variable higher than 4
    .......... variable = 1
    otherwise
    .......... move down
    end

    -----

    I think that when a rule's block (true or otherwise) executes, it should ignore the other block... So when it sets variable to 1, ignore the otherwise block.
    Like in other programming languages...

    variable = 5
    if variable == 5
    variable = 1
    else
    move_down
    end
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    It is constantly checking for the event. If it only looked for the first instance you wouldn't be able to do things like press a button to move.

    Rule: Key "left" is down
    ........ Move left
    otherwise
    ........ Move right
  • Omegas7Omegas7 Member Posts: 37
    Well I wouldn't mind making 2 rules for that...

    Rule: Key 'left' is down
    .......... Move Left.
    end

    Rule: Key 'right' is down
    .......... Move Right.
    end

    -----

    Anyways, is my problem a bug? Or it was planned like that?

    Ty for the help so far btw.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    planned. Thanks for pointing out possibly confusing issues though.
  • Omegas7Omegas7 Member Posts: 37
    I find ignoring the other block when one executes much more useful =P...
    Maybe in a future version? Or an option that says 'Ignore this block if other already executed'.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    You could do this:

    Make a boolean attribute called ThisRuleWasInitiallyTrue = false

    With variable = 8
    Rule(Any): variable > 5 OR ThisRuleWasInitiallyTrue == true
    ..... ThisRuleWasInitiallyTrue = true
    ..... variable =3
    Otherwise:
    ..... Move
Sign In or Register to comment.