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

#1 2009-04-26 12:42:50

N10do64
Scratcher
Registered: 2009-04-26
Posts: 2

Number Variables

IS there a way to make a variable be displayed in text? Such as "You killed [blank] aliens!"
--N

Offline

 

#2 2009-04-26 12:46:57

DawnLight
Scratcher
Registered: 2009-04-25
Posts: 500+

Re: Number Variables

N10do64 wrote:

IS there a way to make a variable be displayed in text? Such as "You killed [blank] aliens!"
--N

No but you could make a sprite to go over the variable.Example:

Sprite:

You Killed (Leave blank space to insert variable} alien!

Variable:
         
Put variable into blank sprite spot.

Hope this helps!  big_smile

Offline

 

#3 2009-04-26 13:55:45

hmnwilson
Scratcher
Registered: 2007-07-04
Posts: 1000+

Re: Number Variables

Actually you can.

First, you need to make a list. Once you've done that, make this script:
http://www.freeimagehosting.net/uploads/ab56871ae2.png
Say the variable was set to 5. The list would look like this:
http://www.freeimagehosting.net/uploads/e627bbfb8d.png
I don't know what exactly you want to do with the text, but you could put it in a "say" block. Use this script:
<say[ <{ list }>[/blocks]

That makes this happen in the sprite:
http://www.freeimagehosting.net/uploads/c4112e90d8.png
It automatically puts spaces between the list items.

And you're done!


I'm taking a break from Scratch until 2.0 comes out. Any messages sent between then and now probably won't be read - sorry.
(Oct. 20, 2011)

Offline

 

#4 2009-04-26 14:10:54

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Number Variables

There is a way, by making a sprite with 10 costumes (0123456789).
Then you just have to make scripts to say each thing.
So, say you wanted to say a 3-digit number.
Just use a script like this:
http://www.freeimagehosting.net/uploads/22681d395f.gif
You just divide the number by whatever the digit is (so if you wanted the thousands digit, you would divide it by 1000) and use the script there. You can also change the "change x by" if you're using different-sized fonts.

Last edited by coolstuff (2009-04-26 14:11:17)

Offline

 

#5 2009-04-26 14:20:46

DawnLight
Scratcher
Registered: 2009-04-25
Posts: 500+

Re: Number Variables

hmnwilson wrote:

Actually you can.

First, you need to make a list. Once you've done that, make this script:
http://www.freeimagehosting.net/uploads/ab56871ae2.png
Say the variable was set to 5. The list would look like this:
http://www.freeimagehosting.net/uploads/e627bbfb8d.png
I don't know what exactly you want to do with the text, but you could put it in a "say" block. Use this script:
<say[ <{ list }>[/blocks]

That makes this happen in the sprite:
http://www.freeimagehosting.net/uploads/c4112e90d8.png
It automatically puts spaces between the list items.

And you're done!

Nice helping!

Offline

 

#6 2009-04-26 15:50:06

N10do64
Scratcher
Registered: 2009-04-26
Posts: 2

Re: Number Variables

Thanks

Offline

 

#7 2009-04-26 16:03:09

DawnLight
Scratcher
Registered: 2009-04-25
Posts: 500+

Re: Number Variables

N10do64 wrote:

Thanks

Your welcome!

Always a pleasure to help someone in need!  big_smile

Offline

 

Board footer