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

#1 2010-06-13 14:57:19

flipysrevenge96
Scratcher
Registered: 2010-04-03
Posts: 4

How do I get a character to say a random quote out of multible phrases

Ok, I'm making a dating sim seeing as there's a lack of them on scratch. I need one of the girls to tell you something about herself when you click the "Ask" button. And i need it randomized rather than her tellng you things in a specific order

Last edited by flipysrevenge96 (2010-06-13 14:59:11)

Offline

 

#2 2010-06-13 15:00:58

samurai768
Scratcher
Registered: 2009-07-21
Posts: 1000+

Re: How do I get a character to say a random quote out of multible phrases

Um, I will help as long as this will be appropriate for kids of all ages.

You make a list of the sayings, and put a (item (any) of list) inside a say block.

It will pick a random saying everytime. But, you might want to put a delete item from list block in there somewhere.

Offline

 

#3 2010-06-13 15:02:41

Wolfie1996
Retired Community Moderator
Registered: 2009-07-08
Posts: 1000+

Re: How do I get a character to say a random quote out of multible phrases

Ah - you can do this by making a list (go to the "variables" pallet, and click "make a list") Type in a different quote to each box on the list, then put something like this:

[when ask button clicked]
[say (item (pick random (1) to (length of [list v]) of [list v] ]

You find the blocks with "[list v]" on them in Variables, and "pick random" in Operators. You could also use "ask" instead of "say"  smile  Hope this helps!


"...Jargon - the practice of never calling a spade a spade, when you might instead call it a manual earth-restructing implement..." - Bill Bryson, Mother Tongue

Offline

 

#4 2010-06-13 15:06:46

samurai768
Scratcher
Registered: 2009-07-21
Posts: 1000+

Re: How do I get a character to say a random quote out of multible phrases

Wolfie1996 wrote:

Ah - you can do this by making a list (go to the "variables" pallet, and click "make a list") Type in a different quote to each box on the list, then put something like this:

[when ask button clicked]
[say (item (pick random (1) to (length of [list v]) of [list v] ]

You find the blocks with "[list v]" on them in Variables, and "pick random" in Operators. You could also use "ask" instead of "say"  smile  Hope this helps!

Oh, you were so close wolfie! But I beat ya  tongue  You can do either of our suggestions.

Both will work  wink

Last edited by samurai768 (2010-06-13 15:06:57)

Offline

 

#5 2010-06-13 19:08:49

flipysrevenge96
Scratcher
Registered: 2010-04-03
Posts: 4

Re: How do I get a character to say a random quote out of multible phrases

Hey guys thanks for the help...and don't worry. this will be appropriate. The only questionable thing is kissing and I'm just drawing a smiley face for that one  tongue . I see the need for you to wonder if my project will be appropriate with all the...erm...."content" in most dating sims (Cough*Newgrounds*Chough) Don't worry. I should be done with it in about 2 more days  tongue

Last edited by flipysrevenge96 (2010-06-13 19:25:17)

Offline

 

#6 2010-06-13 19:28:21

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

Re: How do I get a character to say a random quote out of multible phrases

flipysrevenge96 wrote:

Hey guys thanks for the help... Except, is there a way of doing this without a "list?"and don't worry. this will be appropriate. The only questionable thing is kissing and I'm just drawing a smiley face for that one  tongue .

Sure, you could do it with out a list...but a list is much easier.  Here is a way to do it without a list:

[blocks]
<when[ Sprite  ]clicked>
<set{ Answer_Number }to( <pick random( 1 )to( 6
<if> <(  <{ Answer_Number }><=> 1 )>
<say[ first answer ]for( 2 )secs>
<end>
<if> <(  <{ Answer_Number }><=> 2 )>
<say[ second answer ]for( 2 )secs>
<end>
<if> <(  <{ Answer_Number }><=> 3 )>
<say[ third answer ]for( 2 )secs>
<end>
<if> <(  <{ Answer_Number }><=> 4 )>
<say[ first answer ]for( 2 )secs>
<end>
<if> <(  <{ Answer_Number }><=> 5 )>
<say[ second answer ]for( 2 )secs>
<end>
<if> <(  <{ Answer_Number }><=> 6 )>
<say[ third answer ]for( 2 )secs>
<end>
... and so on up to the total number of answers you want.

Here's how you do it with lists:
<when[ Sprite  ]clicked>
<say[ item (any) of Answer_List ]for( 2 )secs>
[/blocks]


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

Offline

 

#7 2010-06-13 19:34:52

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: How do I get a character to say a random quote out of multible phrases

Seems like everybody already answered your question. No fair, I wanna help.  mad

tongue


Hai.

Offline

 

#8 2010-06-14 17:58:36

flipysrevenge96
Scratcher
Registered: 2010-04-03
Posts: 4

Re: How do I get a character to say a random quote out of multible phrases

You have first dibs on my next question okay fg123? ;D

Offline

 

Board footer