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

#1 2012-03-22 15:10:18

jpsrolls
New Scratcher
Registered: 2010-12-09
Posts: 17

Program greets more than one person

The program will have several volunteers.  Each student is asked to put in his/her name.  Somewhere in the program, the sprite will mention each volunteer's name.  I can do it with one volunteer, but can't figure out how to do it with more.  Thanks in advance.  Judy

Offline

 

#2 2012-03-22 18:21:03

TorbyFork234
Scratcher
Registered: 2012-03-01
Posts: 1000+

Re: Program greets more than one person

Just use lists, when they put in their names use this

when gf clicked
delete [all v] of [names v]
repeat <how many names you want inputed>
ask [what's your name?] and wait
add <answer> to item (last v) of [names v]
end
Now you have all the names stored in the list, to make the sprite say the name there are 2 ways to do it.

One way to do it:
when gf clicked
wait until <you're ready for it to say the names>
say <join<join<join <item (1 v) of [names v]> <item (2 v) of [names v]>><item (3 v) of [names v]>><item (4 v) of [names v]>> // That is to say that you only have 4 names, if there's more, add in more joins and put in item 5 of names and so on and so forth
Another way to do it is (this one you don't need all those joins)
when gf clicked
wait until <you're ready for it to say the names>
set [name counter v] to [0]
repeat <length of [names v]>
change [name counter v] by [1]
say <item <name counter> of [names]> for (3) secs //the 3 can be changed to however long you want
end
Hope this helps!

Offline

 

#3 2012-03-22 19:15:15

ImagineIt
Scratcher
Registered: 2011-02-28
Posts: 1000+

Re: Program greets more than one person

The above post will help. Except don't use the join method if you want an infinite amount of characters.

Offline

 

#4 2012-03-23 08:29:44

jpsrolls
New Scratcher
Registered: 2010-12-09
Posts: 17

Re: Program greets more than one person

Thank you!

Offline

 

Board footer