Discuss Scratch

Zparx
Scratcher
500+ posts

Wait until *n* amount of seconds pass boolean operator?

I think this would be neat to have. You could have a script wait until, say 10 seconds, to do something, but if another condition is met before those 10 seconds pass, you could have it continue then. For instance; <<Wait until 10 seconds pass> OR <(continue) = 1>>, and you could have scripts that only continue until *n* amount of seconds have past, AND another condition is met. For example; <<Wait until 10 seconds pass> AND <(continue) = 1>>

This would be very helpful! I have scripts in a project of mine that would absolutely SHINE if this operator were available.

I know one could easily use the “reset timer/wait until timer =” workaround, but this is simply obsolete if you have more than one script depending on the timer at a time.

What do you think? Are there any workarounds that would work the way I mentioned? (If so, PLEASE speak up because I am in desperate need of it)
Do you support this idea? Leave a comment!

- Z <3

Last edited by Zparx (May 27, 2013 09:11:45)

mitchboy
Scratcher
1000+ posts

Wait until *n* amount of seconds pass boolean operator?

I think there is a workaround for this, just a little time consuming. Try this:

wait (.1) secs
if <(continue)=1>
insert whatever block here
else
wait (.1) secs
if <(continue)=1>
insert whatever block here
else
wait (.1) secs
etc.

You get what I mean right? Just continue this pattern until you get to the desired amount of time. You could use smaller amounts of time to be more accurate, but it would require more blocks.

Capsicum annuum.
scimonster
Scratcher
1000+ posts

Wait until *n* amount of seconds pass boolean operator?

Set a variable to the old timer, then check against that+10. That way, something else can use the timer.

Retired Community Moderator
BTW, i run Google Chrome 41.0.2272.101 on a Linux system - Ubuntu 14.04. NEW: iPad 4th gen. w/retina.

418 I'm a teapot (original - to be read by bored computer geeks)
THE GAME (you just lost)
; THE SEMICOLON LIVES ON IN OUR SIGS
xlk
Scratcher
100+ posts

Wait until *n* amount of seconds pass boolean operator?

Easy:
repeat until <<timer = 10>or<continue=1>>

Zparx
Scratcher
500+ posts

Wait until *n* amount of seconds pass boolean operator?


scimonster wrote:

Set a variable to the old timer, then check against that+10. That way, something else can use the timer.

Ahh. I think I understand what you mean, although I'm not entirely sure. Could you explain for me? I can't really make out what I'm supposed to do.
Zparx
Scratcher
500+ posts

Wait until *n* amount of seconds pass boolean operator?

xlk wrote:

Easy:
repeat until <<timer = 10>or<continue=1>>


Zparx wrote:

I know one could easily use the “reset timer/wait until timer =” workaround, but this is simply obsolete if you have more than one script depending on the timer at a time.

I type things in the original post and express myself clearly so that I don't have to repeat things like this ..

Last edited by Zparx (May 28, 2013 09:44:13)

scimonster
Scratcher
1000+ posts

Wait until *n* amount of seconds pass boolean operator?

Zparx wrote:

scimonster wrote:

Set a variable to the old timer, then check against that+10. That way, something else can use the timer.

Ahh. I think I understand what you mean, although I'm not entirely sure. Could you explain for me? I can't really make out what I'm supposed to do.
Here's a script.

Retired Community Moderator
BTW, i run Google Chrome 41.0.2272.101 on a Linux system - Ubuntu 14.04. NEW: iPad 4th gen. w/retina.

418 I'm a teapot (original - to be read by bored computer geeks)
THE GAME (you just lost)
; THE SEMICOLON LIVES ON IN OUR SIGS
xlk
Scratcher
100+ posts

Wait until *n* amount of seconds pass boolean operator?

You can also suppose scratch is going at a constant speed of 30fps, at which time you can make a variable change until it reaches 30 x seconds you want for it to wait. As always, why do people use seconds instead of frames? seconds can be anything from 30 to 1 frame, depending on lag, making it inconsistent between users with better systems and ones with older systems, for an older system, a half second reload timer could be one frame, giving a huge advantage over a user with an newer computer…
BTW, sorry, must of missed that part about already used timers…

Zparx
Scratcher
500+ posts

Wait until *n* amount of seconds pass boolean operator?

scimonster wrote:

Zparx wrote:

scimonster wrote:

Set a variable to the old timer, then check against that+10. That way, something else can use the timer.

Ahh. I think I understand what you mean, although I'm not entirely sure. Could you explain for me? I can't really make out what I'm supposed to do.
Here's a script.

Yes but what if the sprite depending on the timer consistently resets the timer before the sprite with the workaround has a chance to reach that condition?
Zparx
Scratcher
500+ posts

Wait until *n* amount of seconds pass boolean operator?

xlk wrote:

You can also suppose scratch is going at a constant speed of 30fps, at which time you can make a variable change until it reaches 30 x seconds you want for it to wait. As always, why do people use seconds instead of frames? seconds can be anything from 30 to 1 frame, depending on lag, making it inconsistent between users with better systems and ones with older systems, for an older system, a half second reload timer could be one frame, giving a huge advantage over a user with an newer computer…
BTW, sorry, must of missed that part about already used timers…

This is interesting to me. I have no idea how to implement it into my projects. It surpasses my knowledge of code, which is why I think a lot of scratchers don't rely on this method. Perhaps if you could explain how this would work in a project with a series of scripts or a project?
xlk
Scratcher
100+ posts

Wait until *n* amount of seconds pass boolean operator?

http://scratch.mit.edu/projects/10539767/#player
Take a look at the 2 scratch cats. One changes color every second, the other every 32 frames.
Notice the diference with some clones, and too many clones.
fps: frames per second through a timer
fps2:frames per second with a counter

What I'm trying to demostrate is that in one second, many or barely any things can happen, either 500 frames, or 5 frames.
If you time things with frames, it is consistent, even with lag.

now lets say we had an enemy that moved one pixel every frame, and your character takes one second to reload.
On a fast computer, it's harder, as in one second, that zombie moved ALOT, while on a slow one, in one second, the zombie barely moved.
If you make it so it takes 32 frames to reload, the zombie can move fast or slow, but you'll reload just as fast.

letmethink
Scratcher
100+ posts

Wait until *n* amount of seconds pass boolean operator?

I have an idea which involves a variable and a broadcast.

Before the repeat block you broadcast ‘wait’ and ‘set ’looping?' to 0'
On the recieve broadcast block you put, wait … seconds and then put, set ‘looping?’ to 1
On the looping bit you put, ‘wait until <<’looping?'=1>and/or<>>

I can't be bothered to make a signature. Seriously, who has time to write these things? I have stuff to do, games to make, and you expect me to write a big, long signature? I'm not your slave. You can't tell me what to do, so no, I WON'T write a signature.

Oh, wait…
mitchboy
Scratcher
1000+ posts

Wait until *n* amount of seconds pass boolean operator?

mitchboy wrote:

I think there is a workaround for this, just a little time consuming. Try this:

wait (.1) secs
if <(continue)=1>
insert whatever block here
else
wait (.1) secs
if <(continue)=1>
insert whatever block here
else
wait (.1) secs
etc.

You get what I mean right? Just continue this pattern until you get to the desired amount of time. You could use smaller amounts of time to be more accurate, but it would require more blocks.
This method should work also, however for the .1 seconds in between, it won't check and it's rather time consuming. This is the script condensed (t is equal to the amount of seconds you want, shorter is more reliable):


Capsicum annuum.
Annihimations
Scratcher
26 posts

Wait until *n* amount of seconds pass boolean operator?

Can someone repost what the two scratchers posted in github?
BearSlothCoding
Scratcher
1000+ posts

Wait until *n* amount of seconds pass boolean operator?

Annihimations wrote:

Can someone repost what the two scratchers posted in github?
This post is from 7 years ago, I doubt anybody who posted is still active. You should make your own topic to see if anyone could help you.
EDIT: Yeah, everyone who posted here has quit Scratch.

Last edited by BearSlothCoding (April 19, 2020 21:35:16)

Powered by DjangoBB