Does anybody know a way to fix the position on the screen of where a variable's value is when it is shown? I need my variables to appear in particular places, but every time I reload the file in scratch, the variables default to their position at the top left corner of the presentation screen.
Any help would be greatly appreciated.
Offline
Ah - when you save or upload, the variables must be showing, otherwise they move. You can always get them to hide on startup, but be showing before the green flag is clicked.
To display variables a different way (only applies when there is a limited amount of possible values) you could give a sprite costumes with each possible value written on, then add a script like this:
[blocks]
<switch to costume[ (( <{ variable }> <+> put a number here if wanted ))
[/blocks]
Hope this helps!
Last edited by Wolfie1996 (2010-05-15 10:53:29)
Offline
Well, you can always try using sprites to display your variable. There are two ways to display a variable using sprites. The first one involves stamping:
Make a sprite which has 10 costumes, each one is a number. The numbers should be in this order: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.
Then, make a variable for each place you want. If your variable only goes up to 100, you'll need 3 variables, if it goes up to 1000, you'll need 4, and so forth. Name them "hundreds" "tens" "ones," etc.
Then, use this script to determine the values of these variables:
set (place) to (round ( ( ( ( variableToBeShown ) mod ( place * 10 ) ) / (place) ) + ( 0.5 ) )
For example, for thousands, we would do:
set (thousands) to (round ( ( ( ( variableToBeShown ) mod ( 10000 ) ) / ( 1000 ) ) + (0.5)
Do this for every place down to "ones." The value of the variables is the place value, so if the value of the variable I wanted to print out were 4277, the above code would return "4" because that's the thousands place.
Then, make your sprite go to where you want the variable to start. Make it switch to the costume of the variable for that place, then stamp, then move enough pixels to the left to make room for the next place, stamping it again. After it's printed the number out, clear it.
Method number 2: You can achieve the same effect by making a sprite for each place, and then setting their costume to the place.
Offline