This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-09-13 13:39:03

nickpaterni
New Scratcher
Registered: 2011-09-12
Posts: 2

Project acts strangely when run

I have a fairly complex scratch project that is akin to the old favorite "Breakout" but am getting a weird issue. 

I have several scripts that start out:
[blocks]
<when green flag clicked>
<hide>
<forever if> some_variable = 1
<show>
[/blocks]

If I click the green flag once, everything shows up and starts running; the stuff I expect to show up, and the stuff I expect to be hidden even though the forever if condition is not met.  I verified this with variable reporting on screen.  However, if I click the green flag a second time, everything will restart and be properly hidden.

Any ideas?

Offline

 

#2 2011-09-13 14:59:36

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Project acts strangely when run

Add a wait 0 seconds at the start.

Offline

 

#3 2011-09-13 15:50:37

MyRedNeptune
Community Moderator
Registered: 2007-05-07
Posts: 1000+

Re: Project acts strangely when run

What might be happening is that the script you provided is getting executed before the script that sets your variables at the start of your project, thus the values it reads are those left from the last time you ran the project - this would also explain why it all works the second time you run it.

Like scimonster suggested, you can try adding a wait block at the beginning, but to completely guarantee that it will not bug out, move all the [set variable to] blocks to your variable detecting scripts.


http://i52.tinypic.com/5es7t0.png I know what you're thinking! "Neptune! Get rid of those filthy advertisements and give us back the Zarathustra siggy, you horrible person!" Well, don't worry about it, the Zara siggy will be back soon, new and improved! ^^ Meanwhile, just do what the sig tells you to. >.>

Offline

 

#4 2011-09-13 17:59:59

nickpaterni
New Scratcher
Registered: 2011-09-12
Posts: 2

Re: Project acts strangely when run

Thanks to both scimonster and myredneptune for the responses.  It was more practical, although admittedly less clean to just add the wait 0 seconds to the beginning of those scripts.  It worked like a charm, I think they were indeed executing first before my other script.

Thanks for the help
Nick

Offline

 

#5 2011-09-14 03:30:17

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Project acts strangely when run

You're welcome.  big_smile  Common problem.  tongue

Offline

 

Board footer