Discuss Scratch

Arcanity
Scratcher
46 posts

UNRESOLVED: Counting script acts weirdly

Difficult to explain, but here is the project: http://scratch.mit.edu/projects/25775739/#editor

See inside to see what I mean.

The project is meant to print the number displayed in the Number variable. When the space bar is pressed the number increases.
Currently, there are two scripts in the project that contain a block that increases the variable by 1. As a result, when space is pressed, the printed number increases by 2, as expected.

However, if one of the counting scripts is disconnected, the project still counts by 2 and then by 3 when it reaches 2 digit numbers. When the number reaches 3 digits, the variable changes by 4 etc.

I suspect that this is because each digit, which is a separate clone, counts separately, but why doesn't it do it when I have the other script working as well? Also, I thought that only scripts under the “When I start as clone” hat block affect the clone.

Last edited by Arcanity (Aug. 21, 2014 18:31:27)

vidarfw02
Scratcher
100+ posts

UNRESOLVED: Counting script acts weirdly

All clones will receive the message…so all the clone will do what is under the “When space is pressed” block.

…so when it is a 1 digit number…you have the sprite and 1 clone which will change number by 1…when you get 2 digits…..you get 1 more clone that will change the number…and then when you get 3 digits…yet another clone will change the number…so its not really weird…more expected


So when the number is below 1 it changes by 2, when it get to 10 it changes by 3 and when it get to 100 it changes by 4…and so on…

I can remix…and fix it if you still are stuck…but not tonight..no time…sorry




Arcanity
Scratcher
46 posts

UNRESOLVED: Counting script acts weirdly

vidarfw02 wrote:

All clones will receive the message…so all the clone will do what is under the “When space is pressed” block.

…so when it is a 1 digit number…you have the sprite and 1 clone which will change number by 1…when you get 2 digits…..you get 1 more clone that will change the number…and then when you get 3 digits…yet another clone will change the number…so its not really weird…more expected


So when the number is below 1 it changes by 2, when it get to 10 it changes by 3 and when it get to 100 it changes by 4…and so on…

I can remix…and fix it if you still are stuck…but not tonight..no time…sorry


So why does it count normally when I have this script connected:
when green flag clicked
forever

if <key [space v] pressed?> then
change [Number v] by (1)
end
wait until <not <key [space v] pressed?>>
end
Arcanity
Scratcher
46 posts

UNRESOLVED: Counting script acts weirdly

Bump.
djdolphin
Scratcher
1000+ posts

UNRESOLVED: Counting script acts weirdly

Arcanity wrote:

vidarfw02 wrote:

All clones will receive the message…so all the clone will do what is under the “When space is pressed” block.

…so when it is a 1 digit number…you have the sprite and 1 clone which will change number by 1…when you get 2 digits…..you get 1 more clone that will change the number…and then when you get 3 digits…yet another clone will change the number…so its not really weird…more expected


So when the number is below 1 it changes by 2, when it get to 10 it changes by 3 and when it get to 100 it changes by 4…and so on…

I can remix…and fix it if you still are stuck…but not tonight..no time…sorry


So why does it count normally when I have this script connected:
when green flag clicked
forever

if <key [space v] pressed?> then
change [Number v] by (1)
end
wait until <not <key [space v] pressed?>>
end
Because “when green flag clicked” scripts aren't triggered for clones. Clones are deleted when the green flag is clicked, and the script isn't fired on their creation.

Last edited by djdolphin (Aug. 22, 2014 14:02:09)


!

Powered by DjangoBB