This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2008-05-09 18:41:26

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Variable Display

Help! I've been working on a project for a while but I didn't want to use the variables that scratch has. So I calculated the percentage (for the project) and made four sets of three digits (sprites) so I could display the numbers from the variables. So far sometimes the sprites are accurate, other times they're off by 10% or 1% sometimes others. Any ideas on how to fix this would definitely be appreciated. Heres an example of what I tried: (the variable "one" is the number I want to display)

Tens place: (usually the one that messes up)

<switch to costume[(( (( <{ 1 }> <mod>100  )) / 10  ))

Hundreds place:(normally accurate)
(if)
<if><( (( <{ 1 }> </> 1 )) <=> 100 )>
<switch to costume[ 9          (the digit one)
<else>
<switch to costume[ 10        (the digit zero)

Ones place: (another normal mess up)

<switch to costume[ (( <{ 1 }> <mod> 10 ))

Note: I'm also placing this on all about scratch.

Offline

 

#2 2008-05-09 19:51:13

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Variable Display

I just went through that excercise myself.  Here is what I came up with:

http://scratch.mit.edu/projects/Paddle2SeeFixIt/156911

There's a really simple technique I also saw that didn't use Mod at all...it just took advantange of the fact that the costumes would wrap around if you indexed beyond the top costume.  But the method I did used Mod...along with the Round function.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#3 2008-05-09 20:33:31

Bluestribute
Scratcher
Registered: 2008-01-24
Posts: 1000+

Re: Variable Display

Paddle2See wrote:

I just went through that excercise myself.  Here is what I came up with:

http://scratch.mit.edu/projects/Paddle2SeeFixIt/156911

There's a really simple technique I also saw that didn't use Mod at all...it just took advantange of the fact that the costumes would wrap around if you indexed beyond the top costume.  But the method I did used Mod...along with the Round function.

Do you learn that from me????


http://img247.imageshack.us/img247/1204/bluestributett4.jpg
That's my PSN ID. I know tons of COD4 glitches. Add me as your friend. Oh, and get a headset

Offline

 

#4 2008-05-09 21:28:42

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: Variable Display

Paddle2See wrote:

I just went through that excercise myself.  Here is what I came up with:

http://scratch.mit.edu/projects/Paddle2SeeFixIt/156911

There's a really simple technique I also saw that didn't use Mod at all...it just took advantage of the fact that the costumes would wrap around if you indexed beyond the top costume.  But the method I did used Mod...along with the Round function.

Thanks a bunch for that method, you may see my survey project soon on the website. Thanks again!

Offline

 

Board footer