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
(press 'd' to fire, and the bullet should move across the screen. It doesn't...)
http://scratch.mit.edu/projects/shlop/3200974
Offline
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
(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.
Offline
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
Offline
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
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)
Offline