Discuss Scratch
- Discussion Forums
- » Bugs and Glitches
- » Forever loop only repeats once
- Invisible_Factory
-
Scratcher
500+ posts
Forever loop only repeats once
My browser / operating system: Windows NT 10.0, Chrome 51.0.2704.79, Flash 23.0 (release 0)
Sometimes I will go to other people's projects and check them out. One thing, though is that it isn't working properly. But the owner can't find the glitch and thinks everything is normal.
So, I click “See inside” to see what was wrong. You know how if a script running and is in progress it glows? Well, I saw a script with a forever loop that didn't glow. Now according to logic, forever goes forever, and it will never stop running. So I wonder, why isn't it glowing? How is the forever loop finished?
This means that the forever loop turned into a
which defies the purpose of the forever loop. However, it occurs rarely, maybe once a week, and it has never happened on my own project. I have seen this happen twice.
Also, I tried to manually click on the forever loop to make it run, which made the glow appear but disappear just as quickly. I also tried to reload the page, but it didn't do anything. Does anyone know how to fix this glitch/bug?
Sometimes I will go to other people's projects and check them out. One thing, though is that it isn't working properly. But the owner can't find the glitch and thinks everything is normal.
So, I click “See inside” to see what was wrong. You know how if a script running and is in progress it glows? Well, I saw a script with a forever loop that didn't glow. Now according to logic, forever goes forever, and it will never stop running. So I wonder, why isn't it glowing? How is the forever loop finished?
This means that the forever loop turned into a
repeat (x)(x being undefined, not knowing how many times it repeated)
...
end
which defies the purpose of the forever loop. However, it occurs rarely, maybe once a week, and it has never happened on my own project. I have seen this happen twice.
Also, I tried to manually click on the forever loop to make it run, which made the glow appear but disappear just as quickly. I also tried to reload the page, but it didn't do anything. Does anyone know how to fix this glitch/bug?
- ChatUser2
-
Scratcher
100+ posts
Forever loop only repeats once
How about this?
forever
...
if <...> then
stop [this script v] // stops forever loop
end
...
end
- stickfiregames
-
Scratcher
1000+ posts
Forever loop only repeats once
Which project are you talking about?
- Invisible_Factory
-
Scratcher
500+ posts
Forever loop only repeats once
Forever loops can be stopped.how? I know for a fact putting a “if then” statement that is false inside the forever loop will stop it from functioning, but that was not the case in either of the projects. But
foreverstill should glow because the statement can be made true anytime.
if <> then
end
end
So how can you stop forever loops, without clicking on the stop button or manually stopping it after clicking see inside?
- Invisible_Factory
-
Scratcher
500+ posts
Forever loop only repeats once
Which project are you talking about?I actually don't remember either of their names or links, but the next time I see one I will put it in the OP.
- drmcw
-
Scratcher
1000+ posts
Forever loop only repeats once
It's what the stop blocks doForever loops can be stopped.how? I know for a fact putting a “if then” statement that is false inside the forever loop will stop it from functioning, but that was not the case in either of the projects. Butforeverstill should glow because the statement can be made true anytime.
if <> then
end
end
So how can you stop forever loops, without clicking on the stop button or manually stopping it after clicking see inside?
stop [this script v]
stop [all v]
stop [other scripts in sprite v]
There are also other ways dependent upon the hat block that starts the script, the forever block is in.
Last edited by drmcw (Dec. 11, 2016 15:34:52)
- Invisible_Factory
-
Scratcher
500+ posts
Forever loop only repeats once
oh. Well, if I find it again I will check.It's what the stop blocks doForever loops can be stopped.how? I know for a fact putting a “if then” statement that is false inside the forever loop will stop it from functioning, but that was not the case in either of the projects. Butforeverstill should glow because the statement can be made true anytime.
if <> then
end
end
So how can you stop forever loops, without clicking on the stop button or manually stopping it after clicking see inside?stop [this script v]
stop [all v]
stop [other scripts in sprite v]
There are also other ways dependent upon the hat block that starts the script, the forever block is in.
- midknightking
-
Scratcher
1 post
Forever loop only repeats once
I have the same problem. I can't get my sprite to go on forever.#in python you use for i in range
- Morimop
-
Scratcher
1000+ posts
Forever loop only repeats once
I have the same problem. I can't get my sprite to go on forever.#in python you use for i in rangeDon't necropost please.
- Peashooter10000
-
Scratcher
13 posts
Forever loop only repeats once
I have a similar problem in my project, where the if-then-else block always reads false if it reads false once. My code is:
when green flag clicked
forever
if <[Zombie Ys v] contains (y position) ?> then
Jump Up
repeat until <not <[Zombie Ys v] contains (y position) ?>>
Shoot
end
else
Idle About
end
end
Last edited by Peashooter10000 (Oct. 16, 2023 16:57:21)
- Peashooter10000
-
Scratcher
13 posts
Forever loop only repeats once
Turns out my code had a forever block in one of the custom blocks. Oops.
- CaptainTrooper
-
Scratcher
100+ posts
Forever loop only repeats once
Turns out my code had a forever block in one of the custom blocks. Oops.
I have a similar problem in my project, where the if-then-else block always reads false if it reads false once. My code is:This forum post was in 2016. Please check the dates next time so you dont necropost by accident.when green flag clicked
forever
if <[Zombie Ys v] contains (y position) ?> then
Jump Up
repeat until <not <[Zombie Ys v] contains (y position) ?>>
Shoot
end
else
Idle About
end
end
Also, make a topic separate from others if you have a glitch with scratch and its different from other glitches.
Last edited by CaptainTrooper (Oct. 17, 2023 00:14:11)
- Discussion Forums
- » Bugs and Glitches
-
» Forever loop only repeats once