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
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) endAnyway, hope that helps.
Last edited by amcerbu (2012-09-07 11:18:59)
Offline
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
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"
Offline
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"
Offline
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 ????
Offline
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....
thanks again!!
Offline
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
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....thanks again!!
![]()
"i" would be what person's info you want
eg.
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"
Offline