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

#1 2013-03-22 18:26:57

shlop
New Scratcher
Registered: 2011-07-08
Posts: 2

'repeat until' block apparent misfunction

I stripped down the project i'm working on to just these few sprites and scripts to isolate this problem ( see link below). The 'repeat until' script does not seem to be working in this situation, and I am at a loss as to why... help on this would be much appreciated  smile

(press 'd' to fire, and the bullet should move across the screen. It doesn't...)


http://scratch.mit.edu/projects/shlop/3200974

Offline

 

#2 2013-03-22 20:39:48

Hyperbola
Scratcher
Registered: 2013-03-15
Posts: 100+

Re: 'repeat until' block apparent misfunction

shlop wrote:

I stripped down the project i'm working on to just these few sprites and scripts to isolate this problem ( see link below). The 'repeat until' script does not seem to be working in this situation, and I am at a loss as to why... help on this would be much appreciated  smile

(press 'd' to fire, and the bullet should move across the screen. It doesn't...)


http://scratch.mit.edu/projects/shlop/3200974

You would need the "broadcast [fire] and wait" instead of the normal broadcast, as right now the fire script exits prematurely before the fired variable can be set back to 0. And also the first script does not have a go to mouse pointer, which it should. That fixes your problem right now, but I'm not sure what to do for the rest.


Tip of the whatever: Don't post in threads older than 2 weeks unless your post will actually be useful.
It's the last day of 1.4! *cries* (quote from NeilWest, rest by me) by the time you read this it probably will be 2.0  sad

Offline

 

#3 2013-03-23 04:03:49

shlop
New Scratcher
Registered: 2011-07-08
Posts: 2

Re: 'repeat until' block apparent misfunction

Ah, yes, I understand now - because the 'd' key is inevitably held down for a long enough time for the broadcast script to run more than once, which restarts the fire script before the bullet has reached the edge. And, as you said, before the fired variable can be reset to 0.

This also explains why when I ran the script in single stepping it worked without a problem - when it was running slowly the delay was sufficient to allow the broadcast script to run only once.

Thank you for your help  smile

Offline

 

#4 2013-03-23 17:24:04

Hyperbola
Scratcher
Registered: 2013-03-15
Posts: 100+

Re: 'repeat until' block apparent misfunction

shlop wrote:

Ah, yes, I understand now - because the 'd' key is inevitably held down for a long enough time for the broadcast script to run more than once, which restarts the fire script before the bullet has reached the edge. And, as you said, before the fired variable can be reset to 0.

This also explains why when I ran the script in single stepping it worked without a problem - when it was running slowly the delay was sufficient to allow the broadcast script to run only once.

Thank you for your help  smile

Your welcome. And yes, bugs which appear to change are really weird - they've even made a name for them: http://en.wikipedia.org/wiki/Heisenbug (Copypaste since I'm still a new scratcher even though I've a lot of experience)


Tip of the whatever: Don't post in threads older than 2 weeks unless your post will actually be useful.
It's the last day of 1.4! *cries* (quote from NeilWest, rest by me) by the time you read this it probably will be 2.0  sad

Offline

 

Board footer