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

#1 2012-09-07 07:33:14

Lydialol
New Scratcher
Registered: 2012-09-05
Posts: 8

list

hello!!!
I want to make a list and when I tried i had a problem...I dont want to make a several lists for each player. I want to put the players in the same list...I tried a lot of combinations buuut.....I didnt.... If you know something tell us ...please

I want my list be like this:



                               Players
                               1.name and last name: Karerina Mitropoulos
                                age: 18
                                 ..........................
                               2. name and last name: Logan Henderson
                                  age:......................



etc

thanks for your attention

Offline

 

#2 2012-09-07 11:18:46

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: list

Create a list for first names, a list for last names, a list for age, etc.  You set up what's called a parallel array, where item x of one list corresponds to item x of another list.  So the lists would look like this:

firstnames { Karerina, Logan, etc. }
lastnames { Mitropoulos, Henderson, etc. }
ages { 18, ..., etc. }

You get the idea.  If you want to display data about everyone to the screen (in the form of variables), show the variables "name" and "age" on the stage (by checking the boxes next to them) and then use this script:

repeat until <(i) > (length of [firstnames v])>
set [name v] to (join (item (i) of [firstnames v]) (item (i) of [lastnames v]))
set [age v] to (item (i) of [ages v])
wait until <key [space v] pressed?>
wait until <not<key [space v] pressed?>>
change [i v] by (1)
end
Anyway, hope that helps.

Last edited by amcerbu (2012-09-07 11:18:59)

Offline

 

#3 2012-09-08 13:41:20

Lydialol
New Scratcher
Registered: 2012-09-05
Posts: 8

Re: list

Thank you soo muchhh !!!   smile   smile  It really hepled me !!!  smile   smile

Offline

 

#4 2012-09-08 13:57:27

Lydialol
New Scratcher
Registered: 2012-09-05
Posts: 8

Re: list

only one question the "i" that you ve got at the begginnig...
I cant find it...is there somethig else I can do ?

Offline

 

#5 2012-09-08 14:09:59

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: list

That was a variable I created for going through the list.  Just go to the Variables pane and create a new variable named i.  A variable named i is often used to iterate through lists.  By the way, make sure you include this block at the beginning of your script:

set [i v] to [0]

Offline

 

#6 2012-09-08 14:12:05

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: list

amcerbu wrote:

That was a variable I created for going through the list.  Just go to the Variables pane and create a new variable named i.  A variable named i is often used to iterate through lists.  By the way, make sure you include this block at the beginning of your script:

set [i v] to [0]

That ^. It's can be called anything, commonly "reader", "counter", or "iterator"


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#7 2012-09-08 14:21:32

dvd4
Scratcher
Registered: 2010-06-30
Posts: 1000+

Re: list

you could just put all of it in just one list by adding all of the info in one list.


I made a mod  big_smile  It's called blook!
http://i49.tinypic.com/16ia63p.png

Offline

 

#8 2012-09-08 14:28:46

henley
Scratcher
Registered: 2008-06-21
Posts: 1000+

Re: list

zammer990 wrote:

amcerbu wrote:

That was a variable I created for going through the list.  Just go to the Variables pane and create a new variable named i.  A variable named i is often used to iterate through lists.  By the way, make sure you include this block at the beginning of your script:

set [i v] to [0]

That ^. It's can be called anything, commonly "reader", "counter", or "iterator"

You forgot "index"


"I've worked so hard for you and you give me nothing in return. Do you need help... Or do I?"

Offline

 

#9 2012-09-08 14:49:44

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: list

But using i is a long-lasting convention, especially in C, C++, C#, etc.  If you use i in a project, everyone will know that it's being used to iterate through something.

Last edited by amcerbu (2012-09-08 14:50:08)

Offline

 

#10 2012-09-10 05:39:51

Lydialol
New Scratcher
Registered: 2012-09-05
Posts: 8

Re: list

There is a problem... i make the code and the variables as you said, but when i press the green flag to start over the game, i write name and ages and they dont appear to the list.. We tried with other commands (the blue one "ask what's your name and wait" ) but still nothing.... what we do wrong ????  sad   sad   sad   sad   sad

Offline

 

#11 2012-09-10 06:54:25

Lydialol
New Scratcher
Registered: 2012-09-05
Posts: 8

Re: list

okayy we found it (at last)!! Thanks so much!!
I can't understand what the variables i, name, age where appear near to the list, are... If you can tell us...and I m so sorry about all these questions , but I am now beggin to use scratch and I have no idea....  sad  thanks again!!  smile

Offline

 

#12 2012-09-10 19:42:04

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: list

You can imagine a variable this way.  You define a variable as a place to store information.  You can put something into the variable, and it will be stored until it's changed.  Then, you can retrieve the value of the variable.  It's sort of like a box; you put things into the box, and then take them out again to see what they are.  You can also change what's in the box.  That's crucially what a variable is.

Offline

 

#13 2012-09-11 11:51:30

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: list

Lydialol wrote:

okayy we found it (at last)!! Thanks so much!!
I can't understand what the variables i, name, age where appear near to the list, are... If you can tell us...and I m so sorry about all these questions , but I am now beggin to use scratch and I have no idea....  sad  thanks again!!  smile

"i"  would be what person's info you want
eg.

Code:

1.Karerina Mitropoulos 18
2.Logan Henderson x
3.name 2nd name y
"i" would be the item you want, eg 2 would be "Logan Henderson x"

http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

Board footer