Have you ever made a script do do something, but when you play it, something goes wrong? Then you look at your scripts and you just can't see what's wrong. It should work perfectly. But it doesn't. Here, I've collected the most common problems I encounter when making a script, and I'll tell you how to get around these problems.
Delays
These blocks can cause delays in scripts.
wait () secs
wait until <>
repeat until <>
play sound [. v] until done
say [] for () secs
think [] for () secs
glide () secs to x: () y: ()When these are used, the ENTIRE script will be held up until these actions are completed. For example:
when gf clicked forever if <key [up arrow v] pressed?> next costume wait (0.2) secs end if <key [right arrow v] pressed?> change x by (5)In this script, the right arrow is used to move.
when gf clicked forever if <key [up arrow v] pressed?> next costume wait (0.2) secs when gf clicked forever if <key [right arrow v] pressed?> change x by (5)This is why 1s1s projects are exceptionally impressive.
change [variable v] by [10]and
set [variable v] to [100]It might seem at first that this sort of stuff will never happen, and very few people do this, but actually, this is one of the most common problems I've seen. You could forget that you put one of those blocks there and forgot to remove it.
change x by (5)and the
set x to (5)Colour Sensing
<touching color [#000000]?>and
<color [#FFFFFF] is touching [#000000]?>If sensing isn't working, all I can say is double-check you have the right colours. Be careful if you use the effect blocks
change [color v] effect by (5)
change [brightness v] effect by (5)
change [ghost v] effect by (5)as you would need to adjust the colours in the sensing blocks to match this. You can use this block to reset the effects:
clear graphic effectsWhere possible, use the block
<touching [sprite1 v]?>Using the = Sign
forever if <touching [star v]?> change [score v] by [5] end if <touching [coin v]?> change [score v] by [1] end if <(score)=[100]> say [You Win!!!]So you play the game, collecting stars and coins but the sprite never says that you win. You look at the score and it's 126, so surely you've won by now and the sprite should say so. But no. Because the sprite will only say so if score=100 but score never did =100. You could have gotten 6 coins and then gotten 24 stars, meaning that the score was 96, then 101 but never 100 itself. See the problem?
if <(score) > [99]> say [You Win!!!]Pen not working?
Last edited by PhirripSyrrip (2012-06-11 16:07:29)
Offline
repeat (10) can also delay scripts.
Offline
You might want to also mention the "clear graphic effects" block...I've started to find it very useful when I'm dealing with color, brightness, and ghost all at the same time.
Offline
chanmanpartyman wrote:
repeat (10) can also delay scripts.
I suppose but only by a fraction of a second. It only really messes things up if the repeat (10) block is combined with the blocks I listed above.
Offline
AtomicBawm3 wrote:
You might want to also mention the "clear graphic effects" block...I've started to find it very useful when I'm dealing with color, brightness, and ghost all at the same time.
ok I forgot about that
Last edited by PhirripSyrrip (2012-06-15 11:33:10)
Offline
PhirripSyrrip wrote:
AtomicBawm3 wrote:
You might want to also mention the "clear graphic effects" block...I've started to find it very useful when I'm dealing with color, brightness, and ghost all at the same time.
ok I forgot about that
Sorry, I hardly use it, almost forgot it existed!
Offline