Fundamental Logic problem
I have some code as follows:
Rule "self.a" < 100 then
change attribute a = 110
rotate
Below that rule I have a second rule
Rule "self.a" > 100
change attribute a = 110
move
so I have two separate rules, the first one triggers because a is 0
a gets set to 110
the actor rotates
second rule triggers because a > 100
a still is 110
the actor moves
the actor never stops rotating. Why is this? If i make it happen say on a mouse.x position < 100 and > 100, they are independent and mutually exclusive as I'd expect.
Rule "self.a" < 100 then
change attribute a = 110
rotate
Below that rule I have a second rule
Rule "self.a" > 100
change attribute a = 110
move
so I have two separate rules, the first one triggers because a is 0
a gets set to 110
the actor rotates
second rule triggers because a > 100
a still is 110
the actor moves
the actor never stops rotating. Why is this? If i make it happen say on a mouse.x position < 100 and > 100, they are independent and mutually exclusive as I'd expect.
Comments
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
that way you can see when things trigger and why they continue … and then fix your rule
the first set of rules are virtually identical … as are the second set … and will result in the same results almost immediately
turn off some of them (comment out) … to see which ones you really need … and which ones actually trigger the action/event
as @FryingBaconStudios said:… if there are only 2 conditions … use the Otherwise: section of one rule
@};- MH
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
perhaps I should Edit that to 'as'
can I please have the babushka dolls?
@};- MH
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
For what it's worth, it does the exact same thing in otherwise.
If you change it to be
device.mouse.x < 100
rotate
device.mouse.x > 100
move
they do exclusively what they are supposed to do.
My question is why doesn't the rule update for a variable, unless i put a timer in it?
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Make a new actor
Add an attribute to an actor
set attribute to 0
rule self.a < 100
rotate
change attribute self.a 110
otherwise
rotate 0 speed
still rotates.
until you tell the computer to stop rotating the actor
the computer reads that the self.a < 100 … and follows your instructions to rotate
the changeAttribute: self.a To: is done … but does not affect the persisting rotation behavior
the changeAttribute for self.a must be handled by another rule separated from the rotating behavior
Rule: when
Attribute: self.a ≤ 100
--Rotate
Otherwise:
--Rotate --Speed: 0
Rule: when
Event: touch is pressed
--changeAttribute: self.a To: 110
--Move stuff (here or in separate rule with condition self.a=110)
because of the rotation … you will need your move behavior Relative: to scene
@};- MH
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
while true:
if x < 100:
rotate
x = x + 1
else:
don't rotate
Based on the mouse button behavior for rotate where during a button press it would rotate, i assumed the same would hold true for attributes. My mistake