Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
randomly generating names
Old
pikemeister
Junior Member
 
Status: Offline
Posts: 8
Join Date: Jun 2011
Location: Australia
Default randomly generating names - 07-19-2011, 04:37 AM

how do i randomly generate names from a specific list? .. ie- dan, geoff, bill, robert, so that everytime i ask the user for a string the name is always random. Thanks!
   
Reply With Quote
Old
ElectricKirby
Senior Member
 
ElectricKirby's Avatar
 
Status: Offline
Posts: 164
Join Date: May 2011
Location: Dreamland, Planet Popstar
Default 07-19-2011, 05:35 AM

Go to world > Properties and select "Create New Variable." Click the box that says "Other," and "String" should already be in the dropdown box. Then there should be a checkbox named "Make a List." Check that, then just make a list of all possible names you want the name generator to make. Then you can drag it into any tile where a string is accepted and use "Random item from world.list"


My Favorite Resources:
Uploading Images - http://tinypic.com/

File Sharing - http://www.4shared.com/

Textures - http://www.filterforge.com/

Convertible Game-Ripped Models - http://models-resource.com/

Music - http://www.brawlcustommusic.com/gamelist
   
Reply With Quote
Old
Nighthawk0973
Senior Member
 
Nighthawk0973's Avatar
 
Status: Offline
Posts: 240
Join Date: May 2011
Location: In front of my computer.
Default 07-19-2011, 12:43 PM

Ah, well there's that too. I would've suggested how you would do it in Java. Create the strings for names and than create a number variable and randomize it from say, 1-6. Next create a bunch of 'If' statements that would go:

Code:
if (number == 1){
     Name = "Joe";
}else if (number == 2){
     Name = "Bill";
}else if (number == 3){
     Name == "Ronald McDonald";
}
and so on...
   
Reply With Quote
Hi
Old
pikemeister
Junior Member
 
Status: Offline
Posts: 8
Join Date: Jun 2011
Location: Australia
Default Hi - 07-20-2011, 09:35 PM

hey guys, i've created my list and what not of all the names that i need to randomly generate. From here how do i place the list within a string for it to work properly. Eg - All my names are to randomly generated BEFORE it asks the question - What is my name? Im stuck on this part. Thanks guys
   
Reply With Quote
Old
ElectricKirby
Senior Member
 
ElectricKirby's Avatar
 
Status: Offline
Posts: 164
Join Date: May 2011
Location: Dreamland, Planet Popstar
Default 07-20-2011, 10:28 PM

You want to make a guessing game, I assume? Well, you need to make a String variable that will hold the correct answer. Make an event "When the World Starts", and then drag the Correct Answer variable, and then select "Set Value." Make it set value to anything (Just put random letters, it won't matter in a few seconds). Drag the list of names over to the Correct Answer variable, and then select "Random Item from List". That way, when the world starts, it will set the value once.


My Favorite Resources:
Uploading Images - http://tinypic.com/

File Sharing - http://www.4shared.com/

Textures - http://www.filterforge.com/

Convertible Game-Ripped Models - http://models-resource.com/

Music - http://www.brawlcustommusic.com/gamelist
   
Reply With Quote
hi
Old
pikemeister
Junior Member
 
Status: Offline
Posts: 8
Join Date: Jun 2011
Location: Australia
Default hi - 07-20-2011, 11:13 PM

hey kirby, yeah a guessing game. So basically i need to create 2 variables? One property which lists all the names and then a local variable which is the correct answer is that right? so both are strings? Do i need to create a boolean variable or no? Thanks heaps for your help
   
Reply With Quote
Old
ElectricKirby
Senior Member
 
ElectricKirby's Avatar
 
Status: Offline
Posts: 164
Join Date: May 2011
Location: Dreamland, Planet Popstar
Default 07-21-2011, 01:14 AM

Well, after you do what I just told you, you'll need to make two new variables: A string and a boolean. The new string should be where a popup window appears and asks the user for a string, in this case, the name. Drag that into a method, and set value to whatever. Go into World > Functions, and scroll down until you see "Ask User For a String". Drag that into where you put "Whatever." Below that, have an If/Else statement. If the User-input String Variable matches the Correct Answer Variable, set it to true. If not, set it to false.


My Favorite Resources:
Uploading Images - http://tinypic.com/

File Sharing - http://www.4shared.com/

Textures - http://www.filterforge.com/

Convertible Game-Ripped Models - http://models-resource.com/

Music - http://www.brawlcustommusic.com/gamelist
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2017, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.