# Decimal number line project

Hi, I am trying to make a visual decimal number line for my students. I would like to make an animation that allows me to zoom in/out on a number line. I leave you a sketch so that you can see more clearly what I intend.

Honestly, I have no idea how to start and it occurred to me to save the values and positions in lists to place the clones. I did two lists: listStageDecimals for x positions in the stage and listUserDecimals for numbers kids should see. If you have any better ideas to do it, please let me know.

The first difficulty that I have encountered has been that I don't know how to tell each clone to say the number that corresponds to it and it is only the original sprite that says the numbers.

Here is the project.

Only the one sprite speaks because it's the only one with a SAY in its script. What you need to do is make a when I start as a clone script and put the SAY in that.

To make the animation work right, I think you have to have all the clones except the two nearest to where the user clicks just slide offstage. The two neighbors slide to the edges of the stage, but they drop clones of themselves at the StageDecimals positions (including their starting positions).

Thanks @bh, now each clone says its number. I am now trying to animate the clones. I have gotten the positions of the clones closest to the mouse click (I named them newLeft and newRight). It didn't seem like a good way to do it, but it seems to work. Now I'm trying to animate all the clones, for that I calculate the distance from the edges and pass the new coordinate to a "glide" block. But obviously there is something that I do not understand because the result is painful .

They all glide all the way to the edge. Then all but the neighbors delete themselves. Meanwhile, as the neighbors pass the screen coordinates that should have vertical lines, they make clones of themselves.

So I guess all but the neighbors glide to the edge in one glide, but the neighbors glide 1/10 of the width of the picture, drop a clone, glide another 1/10, etc.

Ok, the animation jump by jump in 1/10 steps wasn't very "real" and I tried to create other 10 subfractions before and then animate all clones at once, but it was impossible for me (I made a mess and I'm afraid I'm still very new to that).
So now I am trying to separate the clones to the edges and then to divide like at the beginning, but I run into a problem: when I try to update the list of values that the children will see (listUserDecimals), the variable j that I use is not updated and I don't know why
To reproduce what happens to me you have to click on the green flag, then click somewhere in the Stage and then run this script.

You can see that j doesn't update even if I go step by step.

J does update, just not from where you think. I put a PAUSE ALL between the SET and the REPEAT, and at that pause J's value is an empty string. I take this to mean that newLeft (we allow spaces in variable names, you know...) isn't in listStageDecimals.

I think if I were writing this program I'd simplify it by putting the ten verticals at multiples of 60, so there'd be an extra 20 steps on the left and right. For one thing, as it is the two rightmost speech balloons are superimposed, but more important, instead of having a list of positions you can just divide or multiply by 60.

But if you take the block between the SET and the REPEAT out and run it, it works, why does this happen?

I think if I were writing this program I'd simplify it by putting the ten verticals at multiples of 60, so there'd be an extra 20 steps on the left and right.

At first I take the measurement of the width of the stage, to be able to resize it later.

instead of having a list of positions you can just divide or multiply by 60.

Yes I think you are right. At first I thought it was better to keep track of the lists to know where the clones were but it seems that it is not necessary. I'm going to redo it.

Another question I have is why do I have to use the WAIT block sometimes to make it work as I expect? What do I have to look out for or take into account?

Ok, here is a new version.
But new problems have arisen around SAY block :-/
Text balloons don't follow their owners when they leave the Stage, so they all huddle around the edges. This has forced me to hide all but the new limits (new_left and new_right).
This makes me wonder what exactly a balloon in Snap is!

And another question, is there any way to get the text of a balloon of a SAY block?
Balloons text follows the sprite or clone that said it and would need to get the text of a specific clone (whose position I know). As I did not know if this was possible, in the end I had to use a table to find the value of the balloon.

Two details would remain before moving on to the reversibility option.
I don't know where or how to put this block to do its job. If I start the program, I click on a section (I wait for the animation to finish), then I have to click on this block manually to make it do its job because if I put it under the "toSeparate" script, crazy things come out.

And the last problem is I don't know what to do with the decimals of the balloons when creating the clones. How can I control the number of decimal places that appear? Sometimes 16 decimal places appear and this can be very confusing for children.

Without using the JavaScript function block, you can just set a sprite-local variable and in another script, forever say the value of the variable.

In this case I think I can't do that, because I don't know what text I have to save until the user do the click.

Then how would you know what text to put in the say block?

I have a lot of clones and I give each one a text through a counter, once each one has its text, the user chooses and I need to know which text he chose and the only clue I have is the position of the clone.

. There is a way to do with with the JavaScript function block, but without it,

and any time you need to

you can just access the variable.

I'm guessing @introlinux doesn't know how to make sprite-local variables so that each clone has its own.

I really should find the time and energy to debug the project but this hasn't been a great time for me to do projects like that, sorry.

Isn't it the same as in Scratch?

Not everybody knows everything about Scratch. :~)

Somebody who (probably) came to Snap! but not from Scratch; I don't see that often.
(Or they did use Scratch but just didn't know about local vars)

Hey, listen, I keep learning things about Snap!, and I'm supposed to be an expert on it. There's just a lot to know. Same for Scratch, I imagine.

This is very interesting. And yes, I don't know how to do that. I'm not a coder, I am a primary school teacher who needs some applications that I have not been able to find anywhere. I only knew about scratch 1.4 more than 10 years ago maybe? And I don't know if there were local variables.
Thanks to both of you, you don't need to debug the program with just a few clues to continue understanding Snap! is enough, thank you very much anyway.

So, before you start making clones, in the original sprite you click Make a Variable and down at the bottom of the window, in the tiny type nobody ever reads (by design, if you're a kid you get quite far in Scratch/Snap! before you need the feature) you choose "for this sprite only." Then, as you make clones, each gets its own variable, whose initial value is the value of the parent at the time you do the cloning.

So one not-uncommon technique is to have the parent sprite assign an appropriate value to its own variable just before making each clone. But also the clone can do it itself.

PS Have I mentioned you should get in touch with Paul Goldenberg?