Any block, way, or extension, to make a wait x seconds thing?

Any block, way, or extension, to make a wait x seconds thing? I know it can be done with the clock component but its kinda confusing... Is there any other way?

Why is it confusing?

You CANNOT do this:

image

because the procedure doThis will be called immediately after you call the wait procedure, it will not wait.

You CAN do this:

image

When you press button2, the clock timer is enabled, but will not fire until the timer interval is reached, then doThis will be run.

This extension does that:

It doesn't, you still have to call the action after the timer fires (delay expires)

1 Like

I don't know if I understood correctly.

What you want to do is execute an action while the timer is active and when the timer ends, it stops performing the action that was called?

This extension does exactly the same thing as the Clock component.

1 Like

This is probably not an ideal approach, but if you really must have an inline delay, you could try using the while test.

These blocks count until the variable count reaches a certain number, then executes a procedure. You need the break block, otherwise you will have an infinite loop. I tested with my emulator and my Pixel 8a and got similar results. YMMV and/or you could try different calculations to achieve the same effect. Anything you want to do after the test must be included inside the test and before the break block.

image

After a bit more testing it also appears to work like this:

demo AIA

whileTimer.aia (3.8 KB)

You will see that there does not appear to be an obvious algorithm for calulating the power values needed for each second (although I only went up to 5), I guess the instructions processor determines how long it takes.