Discuss Scratch
- Discussion Forums
- » Suggestions
- » Wait () Seconds or Until <> Block
- DataLabGames
-
Scratcher
100+ posts
Wait () Seconds or Until <> Block
Here's the block:
Basically, it does what it says it does: Wait for a bit or until a certain condition is fufilled. I know you can workaround like this. It's a variable timer, but it's not a perfectly accurate solution (so far, there is no scratch script that can recreate a accurate timer as accurate as the built-in timer due to screen refresh):
While there is a warkaround to this block, it will save a lot of time considering the fact that control blocks like these generally are used a lot, and also, the workaround isn't a perfect workaround, and can cause problems in projects where milliseconds matter.
Edit:
I just thought about a more useful block that if added, will replace the above block and add even more functionality. The Repeat () Seconds or until <> block.
wait () seconds or until<> ::control
Basically, it does what it says it does: Wait for a bit or until a certain condition is fufilled. I know you can workaround like this. It's a variable timer, but it's not a perfectly accurate solution (so far, there is no scratch script that can recreate a accurate timer as accurate as the built-in timer due to screen refresh):
define Wait (Seconds) seconds or until <Conditon>
repeat until <<Conditon> or <(VarTimer) > ((Seconds) * (30))>>
wait (0) secs
change [VarTimer v] by (1)
end
While there is a warkaround to this block, it will save a lot of time considering the fact that control blocks like these generally are used a lot, and also, the workaround isn't a perfect workaround, and can cause problems in projects where milliseconds matter.
Edit:
I just thought about a more useful block that if added, will replace the above block and add even more functionality. The Repeat () Seconds or until <> block.
repeat () seconds or until <> {
} :: controlThis block will repeat a certain script until the time limit is up or the condition is true. And I'm sure someone will ask, “What if the time limit is reached when the loop is still running?” In that case, the loop stops itself from running any more of its code.Last edited by DataLabGames (May 17, 2021 11:55:02)
- k7e
-
Scratcher
1000+ posts
Wait () Seconds or Until <> Block
About the millisecond thing…
define wait (secs) or until <value>
set [paused time v] to (timer)
wait until << (timer) = ((secs :: custom) + (paused time))> or <value :: custom>>
- TheClaw7654
-
Scratcher
500+ posts
Wait () Seconds or Until <> Block
forever
support
because
it saves time
end
- Thingied
-
Scratcher
1000+ posts
Wait () Seconds or Until <> Block
Semi support. There is a workaround that's simple enough but having it all be in one block would be really convenient
My workaround:
My workaround:
...
set [timer v] to (0)
set [seconds v] to (...)
repeat until <<condition>or<(customtimer)>(seconds)>>
change [customtimer v] by ((1)/(fps))
end
...
Last edited by Thingied (May 17, 2021 18:33:08)
- k7e
-
Scratcher
1000+ posts
Wait () Seconds or Until <> Block
forever
support
because
it saves time
end
forever
please
be
constructive
and
not
block
spam
end
- Discussion Forums
- » Suggestions
-
» Wait () Seconds or Until <> Block