GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Rule Bug.

Omegas7Omegas7 Posts: 37Member
edited 9:00PM 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 Posts: 1,803Head Chef, Member, PRO
    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 Posts: 37Member
    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 Posts: 1,803Head Chef, Member, PRO
    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 Posts: 37Member
    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 Posts: 1,803Head Chef, Member, PRO
    planned. Thanks for pointing out possibly confusing issues though.
  • Omegas7Omegas7 Posts: 37Member
    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 Posts: 1,803Head Chef, Member, PRO
    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
This discussion has been closed.