I can't Repeat my action using Repeat x times

If I click the button the items will be randomize and shown,

What I want to do is random the items for x times every x secs

I’ve done it manually but can’t do it with Repeat x times
pls help

Here is the screen shot

My event

I want to do this for example 3 times and it triggers every 0.5 second

Your repeat event is disabled
Click on it on the left and press D to toggle enable

Disabled events have horizontal line going trough center of text

1 Like

I disabled it because it didn’t work when I used it only repeat 1 time (it will random my array and then set the animation according to the random (it worked fine)) so I wrote the bottom block because I want to do that block not by repeating the shuffle, change, wait writing it all for 3 times or more but I don’t know why when I rewrite it into the disabled block which should provide the same output but doesn’t work well it work only at the first random and change animation once

I think it’s fixed now

I start the timer and when the time reach some value it reset do some actions and add a counter
if counter is greater than some value it stops.
but anyway, thanks for the reply.

2 Likes

Wait inserts a wait or pause where it’s placed only for the direct events and subevents of it but GDevelop continues to run the other events.

When wait is used inside the repeat, it loops around creating new pauses or waits and then continues to execute the rest of the project.

Since the waits were all started at the same time, they all expire at the same time. The “paused” events will then be processed at the same time.

Your solution is a better way of doing it. Waits tend to stack up if they’re allowed to. When used it help to use something that only triggers once or use a variable that gets set the first time like your counter or a boolean.

With your solution, you’ll need to add a way to block multiple presses of the roll button. Maybe with a boolean like IsRolling or CanRoll.

I don’t know the setup of your project. But you can hide the button or change it’s title or disable the interactions. Just remember, hidden objects can still be clicked.

A boolean variable like IsRollingDice works well because you can use it elsewhere to prevent any other interactions.

1 Like

Thanks for the info, I use hide when the items are rolling and added the if visible to click to roll but I think I will be using boolean too to make sure the event can’t happen if it’s rolling.

1 Like

Nice. I love Booleans. They create states just like IsJumping or IsPlaying. You can check visibility in places but a boolean can track an overall state not just one one object. They make events easier to read and follow.

States can get complicated but you need to cover every possibility. You need to expect things like a player repeatedly hitting the same button or wrong button at wrong time or even multiple buttons at the same time.

“Hope for the best and be prepared for the worst”

1 Like