Discuss Scratch

ArcherFuse
Scratcher
8 posts

Loop problem?

I'm trying to make an intro to a game, as a rocket ship blasting off. currently, I have a basic script and it's not working?
it looks like this:
whenclicked
setThrustto1
foreverchangeThrustby1.1*Thrust

and I have another going:
whenclicked
foreverchangexbyThrustchangeybyThrust

but for some reason two loops won't run at the same time? I'm fairly sure I'm not in single step mode but when one loop starts the other ends (I have them run at separate times) any help?

Last edited by ArcherFuse (April 9, 2016 03:03:58)

CookieBatter
Scratcher
22 posts

Loop problem?

Maybe consider adding a broadcast script. I think the reason it's not working is because the signals are getting crossed. This is a lot more complicated than I usually do.
ArcherFuse
Scratcher
8 posts

Loop problem?

Lol I tried that, you see whenever a new loop starts the other one just stops dead. Doesn't matter what kind if it's a “repeat until” or a “forever” it just won't work .-. I think it may be a problem with the editor? I tried making a new project and re-doing the simple script but that didn't help.
footsocktoe
Scratcher
1000+ posts

Loop problem?

ArcherFuse wrote:

I'm trying to make an intro to a game, as a rocket ship blasting off. currently, I have a basic script and it's not working?
it looks like this:
whenclicked
setThrustto1
foreverchangeThrustby1.1*Thrust

and I have another going:
whenclicked
foreverchangexbyThrustchangeybyThrust

but for some reason two loops won't run at the same time? I'm fairly sure I'm not in single step mode but when one loop starts the other ends (I have them run at separate times) any help?

Probably what happens is that the variable thrust quickly becomes too large to be something x could change by.

Set your thrust variable to display on the stage. I think you will be surprised to see what it does.
ArcherFuse
Scratcher
8 posts

Loop problem?

Haha no one seems to understand the problem but thanks anyway, I can manually double click the script and it works perfectly! The thing is when a loop starts the other one stops. Even in other sprites!

Last edited by ArcherFuse (April 9, 2016 03:33:19)

asivi
Scratcher
1000+ posts

Loop problem?

ArcherFuse wrote:

I'm trying to make an intro to a game, as a rocket ship blasting off. currently, I have a basic script and it's not working?
it looks like this:
whenclicked
setThrustto1
foreverchangeThrustby1.1*Thrust

and I have another going:
whenclicked
foreverchangexbyThrustchangeybyThrust

but for some reason two loops won't run at the same time? I'm fairly sure I'm not in single step mode but when one loop starts the other ends (I have them run at separate times) any help?

ArcherFuse wrote:

Haha no one seems to understand the problem but thanks anyway, I can manually double click the script and it works perfectly! The thing is when a loop starts the other one stops. Even in other sprites!
Nothing stops https://scratch.mit.edu/discuss/topic/192992/
drmcw
Scratcher
1000+ posts

Loop problem?

Share the project.
TheLogFather
Scratcher
1000+ posts

Loop problem?

There is nothing wrong with the two scripts as you've given (in terms of running them together) – Scratch will run them concurrently when you click green flag (though, as footsocktoe says, your thrust variable is going to become large VERY quickly, because it's MORE THAN DOUBLING at each pass, and so will make the sprite shoot to the top-right corner** as soon as you click green-flag – unless, maybe, you actually have "set thrust to 1.1*thrust“, rather than ”change thrust by…").

If that's not what is happening, then there is something else going on somewhere else that means we will need to see the project to find it.

OTOH, I don't really understand why you think the two scripts need to be separate – why can't you combine them…?

** Actually, I forgot that Scratch does some really weird things when you try to set the x,y positions to some vary large values. The behaviour can get pretty erratic depending on the specific values you use. That means your sprite could do all sorts of very odd things as “thrust” heads off beyond the stratosphere and into the far reaches of the universe…

Last edited by TheLogFather (April 9, 2016 15:44:51)

ArcherFuse
Scratcher
8 posts

Loop problem?

Yeah, I forgot to add in the “wait 0.1 seconds” in my original post, but I do believe it's a problem with the editor? I've tried it with different scripts in different sprites and it has the same problem. I'll try downloading the offline editor.

Last edited by ArcherFuse (April 9, 2016 15:53:38)

AwesomeCreator9875
Scratcher
100+ posts

Loop problem?

If the variable doesn't change so fast then the thrust probably is really high when you click the green flag.

Last edited by AwesomeCreator9875 (April 9, 2016 15:57:17)

TheLogFather
Scratcher
1000+ posts

Loop problem?

ArcherFuse wrote:

Yeah, I forgot to add in the “wait 0.1 seconds” in my original post, but I do believe it's a problem with the editor?
The extra wait is gonna make little difference – it's still more than doubling the thrust variable ten times per second. After one second it has become much greater than 2^10, i.e. >>1024. I really think that's not what you intend…
(Again, I wonder if the script you really have in your project is *setting* the value of thrust in the loop rather than *changing* it, which is why you're not seeing it become so large so quickly in your project…?)

As for “a problem with the editor”, that's highly unlikely. I have a pretty intimate knowledge of the quirks and glitches in Scratch, and this sounds to me like there's something else going on somewhere with your scripting.

I'd suggest you show the thrust variable and watch how it behaves when you start the project, as well as how the sprite behaves that's moving with the thrust. That might provide a clue that you (or we) can investigate further. Ultimately, though, you may well have to share the project for us to find out what's really going on.

Last edited by TheLogFather (April 9, 2016 16:29:21)

Carpit999
Scratcher
100+ posts

Loop problem?

Try to do these instead:
whenclickedsetThrustto1foreverchangeThrustby1.1*ThrustwaitNumberabove0.6secswhenclickedforeverchangexbyThrustchangeybyThrustwaitNumberalsoabove0.6secs
This makes it so that it doesn't change the thrust by something nonstop, but it waits a bit before repeating.

Powered by DjangoBB