Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Why aren't my "Wait Until" functions working more than once?
- ItWasNotSane
- New Scratcher
5 posts
Why aren't my "Wait Until" functions working more than once?
So, I'm working on a project for school, on a different account, and I've probably bitten off a bit more than I can chew, but I had thought that I was about halfway done. That was, until I actually tested my code. The game is a story game that uses a platformer engine to move around. I was using a lot of “when flag clicked” -> "wait until =“ -> ”do action“ type loops, which are only working once for each. That's fine for the ”Scene“ variable, which indicates which scene the game is in, and obviously, a given scene isn't going to play more than once, but to give an example of two that are being extra problematic for me, I synced each of the backdrops up to a variable, which I creatively named ”Backdrop," I tried to use that variable for a lot of sprites to dictate when and where they would show up, but it only seems to work the first time.
Here is sort of what it looks like, in case my explanation has been difficult to understand:
I've tried placing the above inside of a forever loop, or a “repeat until” block, but it still seems to only work once, when it should be repeating.
Another example of a slightly more complicated one of these non-functional systems is the one I tried to use to make the backdrop switch when the character that the player controls hit a certain X value. It worked fine the first time, but didn't work at all afterwards.
How can I fix this so that they work no matter how many times they are used? Do I change the “wait until” blocks into “If–then” blocks, and then put them inside a forever, or “repeat until” block? I'm not exactly sure what I've done wrong. Also, sorry if my explanation dragged on.
Here is sort of what it looks like, in case my explanation has been difficult to understand:
when green flag clicked
wait until <(Backdrop) = [1]>
hide
wait until <[Backdrop] = [2]>
show
I've tried placing the above inside of a forever loop, or a “repeat until” block, but it still seems to only work once, when it should be repeating.
Another example of a slightly more complicated one of these non-functional systems is the one I tried to use to make the backdrop switch when the character that the player controls hit a certain X value. It worked fine the first time, but didn't work at all afterwards.
define border check
repeat until <[Scene] = [ending]>
if <<[Backdrop] = [1]> or <[Backdrop] = [2]>> then
wait until <(x position) = [261]>
next backdrop
end
if <<[Backdrop] = [2]> or <[Backdrop] = [3]>> then
wait until <(x position) = [-261]>
next backdrop
end
end
How can I fix this so that they work no matter how many times they are used? Do I change the “wait until” blocks into “If–then” blocks, and then put them inside a forever, or “repeat until” block? I'm not exactly sure what I've done wrong. Also, sorry if my explanation dragged on.
- The_Creator-ice
- Scratcher
49 posts
Why aren't my "Wait Until" functions working more than once?
This entire loops only repeats if scene = ending if you want this to play for than once try putting a forever lop since the wait until only run once.
- The_Creator-ice
- Scratcher
49 posts
Why aren't my "Wait Until" functions working more than once?
Btw can you show me the link of the project so, I can better understand what you want to do. Thanks I hope I solved your bug.
- firedestroyer1
- Scratcher
72 posts
Why aren't my "Wait Until" functions working more than once?
Hello! I don't know of how much help I can be, becuase normally the script at the top should work with a forever loop (will only run once without one). Here's an example of a similar? script that I think is what you're trying to achieve.
sorry for the huge image.
Some issues I think might be the case:
If these aren't the problem, please let me know & share project link. It's a good idea anyways to make sure that what you think the problem is acutally what the problem is.
sorry for the huge image.
Some issues I think might be the case:
- Not in a forever loop
Not using BACKDROP_NUMBER, using something else
Script isn't actually running.
If these aren't the problem, please let me know & share project link. It's a good idea anyways to make sure that what you think the problem is acutally what the problem is.
- CoconutGator
- Scratcher
1000+ posts
Why aren't my "Wait Until" functions working more than once?
As others have said, it's best to link your project.
You may want to check your code to ensure that you do not have any “stop all” blocks or “stop other scripts in this sprite” blocks for the sprite that is having issues.
You may want to check your code to ensure that you do not have any “stop all” blocks or “stop other scripts in this sprite” blocks for the sprite that is having issues.
- ItWasNotSane
- New Scratcher
5 posts
Why aren't my "Wait Until" functions working more than once?
I would, but it's not shared, and I can't access it, because I forgot how to sign in to my school account, thank you for the advice, though! Btw can you show me the link of the project so, I can better understand what you want to do. Thanks I hope I solved your bug.
- BasilPepper
- Scratcher
26 posts
Why aren't my "Wait Until" functions working more than once?
So, I'm working on a project for school, on a different account, and I've probably bitten off a bit more than I can chew, but I had thought that I was about halfway done. That was, until I actually tested my code. The game is a story game that uses a platformer engine to move around. I was using a lot of “when flag clicked” -> "wait until =“ -> ”do action“ type loops, which are only working once for each. That's fine for the ”Scene“ variable, which indicates which scene the game is in, and obviously, a given scene isn't going to play more than once, but to give an example of two that are being extra problematic for me, I synced each of the backdrops up to a variable, which I creatively named ”Backdrop," I tried to use that variable for a lot of sprites to dictate when and where they would show up, but it only seems to work the first time.
Here is sort of what it looks like, in case my explanation has been difficult to understand:when green flag clicked
wait until <(Backdrop) = [1]>
hide
wait until <[Backdrop] = [2]>
show
I've tried placing the above inside of a forever loop, or a “repeat until” block, but it still seems to only work once, when it should be repeating.
Another example of a slightly more complicated one of these non-functional systems is the one I tried to use to make the backdrop switch when the character that the player controls hit a certain X value. It worked fine the first time, but didn't work at all afterwards.define border check
repeat until <[Scene] = [ending]>
if <<[Backdrop] = [1]> or <[Backdrop] = [2]>> then
wait until <(x position) = [261]>
next backdrop
end
if <<[Backdrop] = [2]> or <[Backdrop] = [3]>> then
wait until <(x position) = [-261]>
next backdrop
end
end
How can I fix this so that they work no matter how many times they are used? Do I change the “wait until” blocks into “If–then” blocks, and then put them inside a forever, or “repeat until” block? I'm not exactly sure what I've done wrong. Also, sorry if my explanation dragged on.
Hmm… I'm not sure about that, there's not wait until block.
If that bird tube ever talks to me again, I'm going to destroy it. - Amity Blight
- TheWeeklyReader
- Scratcher
100+ posts
Why aren't my "Wait Until" functions working more than once?
sorry if this is kinda unrelated or something, but there is a wait until block in controlSo, I'm working on a project for school, on a different account, and I've probably bitten off a bit more than I can chew, but I had thought that I was about halfway done. That was, until I actually tested my code. The game is a story game that uses a platformer engine to move around. I was using a lot of “when flag clicked” -> "wait until =“ -> ”do action“ type loops, which are only working once for each. That's fine for the ”Scene“ variable, which indicates which scene the game is in, and obviously, a given scene isn't going to play more than once, but to give an example of two that are being extra problematic for me, I synced each of the backdrops up to a variable, which I creatively named ”Backdrop," I tried to use that variable for a lot of sprites to dictate when and where they would show up, but it only seems to work the first time.
Here is sort of what it looks like, in case my explanation has been difficult to understand:when green flag clicked
wait until <(Backdrop) = [1]>
hide
wait until <[Backdrop] = [2]>
show
I've tried placing the above inside of a forever loop, or a “repeat until” block, but it still seems to only work once, when it should be repeating.
Another example of a slightly more complicated one of these non-functional systems is the one I tried to use to make the backdrop switch when the character that the player controls hit a certain X value. It worked fine the first time, but didn't work at all afterwards.define border check
repeat until <[Scene] = [ending]>
if <<[Backdrop] = [1]> or <[Backdrop] = [2]>> then
wait until <(x position) = [261]>
next backdrop
end
if <<[Backdrop] = [2]> or <[Backdrop] = [3]>> then
wait until <(x position) = [-261]>
next backdrop
end
end
How can I fix this so that they work no matter how many times they are used? Do I change the “wait until” blocks into “If–then” blocks, and then put them inside a forever, or “repeat until” block? I'm not exactly sure what I've done wrong. Also, sorry if my explanation dragged on.
Hmm… I'm not sure about that, there's not wait until block.If that bird tube ever talks to me again, I'm going to destroy it. - Amity Blight
Last edited by TheWeeklyReader (Nov. 10, 2022 03:28:43)
- Discussion Forums
- » Help with Scripts
- » Why aren't my "Wait Until" functions working more than once?