New to GS and need help with loops
dolphingames
Member Posts: 3
I have the following, but it's not working consistently. I want a loop to run 4 times, but I don't get the same results every time. I suspect it might have something to do with the timer, but not sure. Is there something wrong with the logic?
Rule: Actor touch pressed
--Change Attribute: self.counter to 1
--Timer - every 0 seconds
----Rule: Attribute self.counter < 5
----Log Debugging Statement: self.counter
----Change Attribute: self.counter to self.counter + 1
Rule: Actor touch pressed
--Change Attribute: self.counter to 1
--Timer - every 0 seconds
----Rule: Attribute self.counter < 5
----Log Debugging Statement: self.counter
----Change Attribute: self.counter to self.counter + 1
Comments
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
You should get consistent results if you do it this way:
Rule: Actor touch pressed
-- Change Attribute: self.doLoop To: true
Rule: When doLoop is true
--Change Attribute: self.counter to 1
--Timer - every 0 seconds
----Rule: Attribute self.counter < 5
------Log Debugging Statement: self.counter
------Change Attribute: self.counter to self.counter + 1
----Otherwise
------Change Attribute: doLoop To: false