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

#1 2010-06-19 19:35:34

AhsokaWhitesun
Scratcher
Registered: 2009-11-30
Posts: 2

Variables

So I'm trying to make a name gen (LIke the ultimate warriors name gen). I'm making two lists, one for each half of the name. Now I don't know how to get it to
a. get it to put the two together (randomly)
b. get the name it generates to show up
Can anyone help?
TIA,
Soka


Nari Kuchsaki

Offline

 

#2 2010-06-19 19:47:55

The-Whiz
Scratcher
Registered: 2007-07-09
Posts: 1000+

Re: Variables

Here:
http://i653.photobucket.com/albums/uu259/The-Whiz_photos/NameScript.gif
The 'Name 1' list is the first part of the name, and the 'Name 2' list the second. The (item [any] of [list]) block picks a random item of the list. the (join [] []) block puts two strings together, and this one says (join [Name] (join [ ] [Name])), joining the first name, then  space, then the last name. The say block says the value of the full name.

Last edited by The-Whiz (2010-06-19 19:55:22)

Offline

 

#3 2010-06-19 19:51:06

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

Re: Variables

Well, I'd suggest making a list for the possible parts of the name, or two if you want the halves to consist of different possible parts. For instance, if you want them both to come from the same list of halves of names, make one list, otherwise, make two. Fill the list(s) up with your name halves.

Then use the "Pick random" block to decide which halves go, and the join block to make the finished product.

The below example assumes you're using one list, called "half." It uses two variables to store the halves, and another one to store the finished product:

Code:

When Green Flag clicked
set [half1] to (item (pick random (1) to (length of [half])) of [half])
set [half2] to (item (pick random (1) to (length of [half])) of [half])
set [name] to (join (half1) (half2))

Or, graphically:
http://i46.tinypic.com/2yjoeag.gif

It should work fine. If you made 2 lists, just change the second block which picks random items to this; which essentially just changes the list:

Code:

set [half2] to (item (pick random (1) to (length of [halftwo])) of [halftwo])

Or,
http://i50.tinypic.com/169hnx2.gif
Hope that helped!

EDIT - TheWhiz's way is better, much simpler.  smile

Last edited by coolstuff (2010-06-19 19:57:10)

Offline

 

#4 2010-06-20 17:37:26

AhsokaWhitesun
Scratcher
Registered: 2009-11-30
Posts: 2

Re: Variables

yikes  thanks guys!!!!! It's working!!!


Nari Kuchsaki

Offline

 

#5 2010-06-20 20:08:20

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

Re: Variables

AhsokaWhitesun wrote:

yikes  thanks guys!!!!! It's working!!!

Glad to hear it!  smile

Offline

 

#6 2010-06-22 16:04:52

nyleve
Scratcher
Registered: 2007-10-22
Posts: 2

Re: Variables

Look at my Insult Generator!

Offline

 

#7 2010-06-22 17:41:09

melikecheese
Scratcher
Registered: 2010-06-09
Posts: 500+

Re: Variables

Insult generator???


http://i51.tinypic.com/987rb5.jpg
I am Dave! Yognaught.

Offline

 

#8 2010-06-23 01:49:04

Chrischb
Scratcher
Registered: 2008-07-24
Posts: 1000+

Re: Variables

nyleve wrote:

Look at my Insult Generator!

Please don't make off-topic posts.  sad


I fall: It's a tragedy. You fall: It's comedy.
Hmph enjoy your fall - I get a lovely spring... without pans of new leaves.

Offline

 

#9 2010-06-23 10:07:09

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: Variables

Lol, without checking, I bet the Insult Generator is not off-topic Chrisb. I made a name generator that did redneck, rapper, and rpg names. What makes these generators on topic is that they do exactly what the op asked about.

ps. I never uploaded mine btw


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

#10 2010-06-23 11:19:26

Uchum27
Scratcher
Registered: 2009-07-10
Posts: 6

Re: Variables

Does anyone know how to make a variable into a slideing variable/a variable with a slide to move and change the variable?

Offline

 

#11 2010-06-23 11:29:16

da123
Scratcher
Registered: 2010-01-15
Posts: 35

Re: Variables

Uchum27 wrote:

Does anyone know how to make a variable into a slideing variable/a variable with a slide to move and change the variable?

Right click on the variable and select "slider."

Offline

 

#12 2010-06-23 21:33:01

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

Re: Variables

da123 wrote:

Uchum27 wrote:

Does anyone know how to make a variable into a slideing variable/a variable with a slide to move and change the variable?

Right click on the variable and select "slider."

Good answer! Also, to add onto what da123 said, you can right click on the variable display while it is a slider and select "set slider min and max" to fully adjust your slider settings.

In the future, it's probably a good idea to make your own topics about these kinds of inquiries rather than posting it on irrelevant threads. Thanks!

Offline

 

#13 2010-06-23 21:44:45

The-Whiz
Scratcher
Registered: 2007-07-09
Posts: 1000+

Re: Variables

coolstuff wrote:

da123 wrote:

Uchum27 wrote:

Does anyone know how to make a variable into a slideing variable/a variable with a slide to move and change the variable?

Right click on the variable and select "slider."

Good answer! Also, to add onto what da123 said, you can right click on the variable display while it is a slider and select "set slider min and max" to fully adjust your slider settings.

In the future, it's probably a good idea to make your own topics about these kinds of inquiries rather than posting it on irrelevant threads. Thanks!

I didn't learn that until I had used Scratch for about 2.5 years.  tongue

Offline

 

Board footer