Discuss Scratch

ThePelicanBird
Scratcher
24 posts

Repeat ( ) seconds

That the action inside repeat for ( ) seconds! That would be cool!
Zekrom01
Scratcher
1000+ posts

Repeat ( ) seconds

...
reset timer
repeat until <(timer) > (how many seconds you want it to repeat for)>
...
end
...
No support, use that

Last edited by Zekrom01 (Feb. 19, 2016 20:48:53)

gdpr533f604550b2f20900645890
Scratcher
1000+ posts

Repeat ( ) seconds

Zekrom01 wrote:

...
reset timer
repeat until <(timer) = (how many seconds you want it to repeat for)>
...
end
...
No support, use that
Change the = to a >. This is a common programming trap; the condition is only checked before the next iteration begins, not during the entire loop, so unless the iteration ends at exactly the time, the loop will run forever!
Zekrom01
Scratcher
1000+ posts

Repeat ( ) seconds

Chibi-Matoran wrote:

Zekrom01 wrote:

...
reset timer
repeat until <(timer) = (how many seconds you want it to repeat for)>
...
end
...
No support, use that
Change the = to a >. This is a common programming trap; the condition is only checked before the next iteration begins, not during the entire loop, so unless the iteration ends at exactly the time, the loop will run forever!
Oh

Last edited by Zekrom01 (Feb. 19, 2016 20:48:58)

DaSpudLord
Scratcher
1000+ posts

Repeat ( ) seconds

Chibi-Matoran wrote:

Zekrom01 wrote:

...
reset timer
repeat until <(timer) = (how many seconds you want it to repeat for)>
...
end
...
No support, use that
Change the = to a >. This is a common programming trap; the condition is only checked before the next iteration begins, not during the entire loop, so unless the iteration ends at exactly the time, the loop will run forever!
Yeah. And what if you are using the timer? I semi-support as per the workaround.
alexphan
Scratcher
1000+ posts

Repeat ( ) seconds

DaSpudLord wrote:

And what if you are using the timer?

set [mytimer v] to ((timer) + (amount of time wanted))
repeat until <(timer) > (mytimer>
...
end

You can use this workaround if the timer is being used elsewhere.

Last edited by alexphan (Feb. 19, 2016 22:18:53)

ThePelicanBird
Scratcher
24 posts

Repeat ( ) seconds

I get those things, but do you think that it will be cool that scratxh has that kind of block?
alexphan
Scratcher
1000+ posts

Repeat ( ) seconds

ThePelicanBird wrote:

I get those things, but do you think that it will be cool that scratxh has that kind of block?

It would, but you can already kind of make the block with the things we have now
Vienradze
Scratcher
500+ posts

Repeat ( ) seconds

ThePelicanBird wrote:

I get those things, but do you think that it will be cool that scratxh has that kind of block?
Yes
Sheep_tester
Scratcher
500+ posts

Repeat ( ) seconds

repeat (1) secs::control cstart
wait (2) secs
end
How would this behave?

I'm assuming once 1 second has passed, the script will stop doing whatever it is doing and go on past the loop. In that case,
when green flag clicked
set [mode v] to (0)
broadcast [repeat secs v] and wait
when I receive [repeat secs v]
if <(mode)=[0]>
set [t v] to (((days since 2000)*(86400))+(seconds::grey))
wait until <((days since 2000)*(86400))>(t)>
set [mode v] to [1]
broadcast [repeat secs v]
end
when I receive [repeat secs v]
if <(mode)=[0]>
forever
...
end
end
Warning: I haven't tested this so please notify me if it happens to not work.
ThePelicanBird
Scratcher
24 posts

Repeat ( ) seconds

I Think that in that kind of actions, it automaticly stops!

If () and () and () and () and () and () and () and () and () and () and () and () and () and () and () and () = ()

So useful!

Last edited by ThePelicanBird (Feb. 20, 2016 19:06:44)

Sheep_tester
Scratcher
500+ posts

Repeat ( ) seconds

ThePelicanBird wrote:

Sheep_tester wrote:

repeat (1) secs::control cstart
wait (2) secs
end
How would this behave?

I'm assuming once 1 second has passed, the script will stop doing whatever it is doing and go on past the loop.
Yeah, but in that kind of actions, it ends while the typed seconds have passed!


when i rekt someone
say [Get rekt]
show (shades)
change [Guys rekt] by (1)
So was I right? (I meant that the wait block would only operate for 1 second and then the loop would stop its scripts)
oh and don't blockspam
ThePelicanBird
Scratcher
24 posts

Repeat ( ) seconds

when I receive [Rekt]
play all sound in the group [MLG]
say something from the group [MLG Words]
do a dramatic exit

Last edited by ThePelicanBird (Feb. 20, 2016 19:12:26)

asivi
Scratcher
1000+ posts

Repeat ( ) seconds

This might be a workaround
set (secs to repeat) to ((timer) + (0)) // where says 0 put the seconds to repeat
repeat until <(timer) > (secs to repeat)>

end

Edit:
Sorry, i had not noticed this

alexphan wrote:

DaSpudLord wrote:

And what if you are using the timer?

set [mytimer v] to ((timer) + (amount of time wanted))
repeat until <(timer) > (mytimer>
...
end

You can use this workaround if the timer is being used elsewhere.
Greets.

Last edited by asivi (Feb. 20, 2016 21:06:56)

Sheep_tester
Scratcher
500+ posts

Repeat ( ) seconds

alexphan wrote:

DaSpudLord wrote:

And what if you are using the timer?

set [mytimer v] to ((timer) + (amount of time wanted))
repeat until <(timer) > (mytimer>
...
end

You can use this workaround if the timer is being used elsewhere.
Issues:
1) And what if you are constantly resetting the timer to detect the stop button?
2) And what if the script inside takes longer than the loop is supposed to run? It's supposed to stop, by the way:

ThePelicanBird wrote:

I Think that in that kind of actions, it automaticly stops!
DaSpudLord
Scratcher
1000+ posts

Repeat ( ) seconds

Sheep_tester wrote:

repeat (1) secs::control cstart
wait (2) secs
end
How would this behave?

I'm assuming once 1 second has passed, the script will stop doing whatever it is doing and go on past the loop.
I thought it would be like the repeat until <> block, where every time it finished doing what was inside of the c loop, it would check the condition (in this case, the condition being whether the required amount of time has passed), and then decide whether to repeat the loop or continue onward. Like the repeat until <> block, the loop would not stop halfway.
ThePelicanBird
Scratcher
24 posts

Repeat ( ) seconds

DaSpudLord wrote:

Sheep_tester wrote:

repeat (1) secs::control cstart
wait (2) secs
end
How would this behave?

I'm assuming once 1 second has passed, the script will stop doing whatever it is doing and go on past the loop.
I thought it would be like the repeat until <> block, where every time it finished doing what was inside of the c loop, it would check the condition (in this case, the condition being whether the required amount of time has passed), and then decide whether to repeat the loop or continue onward. Like the repeat until <> block, the loop would not stop halfway.

Yeah, that would be cool!
when green flag clicked
move (Banana!) steps
Zekrom01
Scratcher
1000+ posts

Repeat ( ) seconds

Deleted

Last edited by Zekrom01 (Feb. 24, 2016 00:56:53)

pvz_pro
Scratcher
500+ posts

Repeat ( ) seconds

no support
reset timer
repeat until <(timer)>(seconds::grey)>

end
Paddle2See
Scratch Team
1000+ posts

Repeat ( ) seconds

It looks like this is a duplicate topic of this one over here so I'll close it to keep the conversation all in one place.

Please use the existing topic in the link above.

Powered by DjangoBB