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

#1 2010-06-20 20:41:09

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

List Question

I have this script:
When green flag clicked
Delete all of List 2
Repeat (pick random (1) to (5)
Set Choosing to item any of List 1
If not Choosing = item any of List 2
Add Choosing to List 2
Else
Delete item Choosing of List 2
Add Choosing to List 2
Say List 2

It works okay, but part of the game is that it does not say any item twice.

How do make it so it fits the rules of the game?

Offline

 

#2 2010-06-20 21:33:36

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

Re: List Question

Hm... What are the rules of the game? Then I might be able to help you  smile

Offline

 

#3 2010-06-20 23:51:39

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

Re: List Question

coolstuff wrote:

Hm... What are the rules of the game? Then I might be able to help you  smile

Well, it's a pizza making game, where you make pizzas, and the customers order random pizzas. It would be easier for them to say "Can I have a Pepperoni Olive Pizza?"
than "Can I have a Pepperoni Olive Pineapple Pepperoni Olive pizza?" right?

Offline

 

#4 2010-06-21 03:04:40

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: List Question

Here's your script:

http://img143.imageshack.us/img143/4721/240randompizzascript.png

It's too wide for posts, so it'll be shrunken down... click here to see it in full size.

How the script works:
  • Topping 1 is set to a random topping in the list of toppings. The join block with the setting of the Topping variables is so there can be a space at the end - this is for the part when the sprite says the sentence.
  • Topping 2 is set to a random topping. If Topping 2 is the same topping as Topping 1, Topping 2 will set to a random topping until it is a different topping from Topping 1.
  • Topping 3 is set to a random topping. If Topping 3 is the same topping as Topping 1 or Topping 2, Topping 3 will set to a random topping until it is different from Topping 1 and Topping 2.
  • All three toppings are ready (and different) - now the sprite says the wanted pizza. If spaces weren't put into the Topping variables earlier, we would have to put them in here - and the script would be even wider!

Hope I helped!  big_smile  Any questions?


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#5 2010-06-21 07:15:53

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

Re: List Question

Or if you wanted an infinite number of toppings, you could do this:
http://i653.photobucket.com/albums/uu259/The-Whiz_photos/ToppingsScript.gif

Add all your toppings to the "Toppings" list, and replace the min and max Toppings variables with your own values in the script. Also, the script automatically calibrates how long it says the "I want a _ pizza" based on the number of toppings - 1 topping yields 2 seconds, 2 toppings 3, and 3 4, etc.

Last edited by The-Whiz (2010-06-21 07:16:26)

Offline

 

#6 2010-06-21 23:48:39

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

Re: List Question

You both have great scripts, and both work, but I want infinite toppings  tongue  Thank you both  big_smile

Last edited by samurai768 (2010-06-21 23:48:53)

Offline

 

Board footer