| |
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 31 May 2014 06:53 PM |
local tablename = {1, "Panda", "Potato"}
for key, value in pairs(tablename) do print(key, value) end
>1 1 >2 Panda >3 Potato
Basically key is the index of the tablename, and value is tablename[key]
|
|
|
| Report Abuse |
|
|
| |
|
zakarq
|
  |
| Joined: 10 Oct 2010 |
| Total Posts: 883 |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
zakarq
|
  |
| Joined: 10 Oct 2010 |
| Total Posts: 883 |
|
| |
|
| |
|
| |
|
|
| 31 May 2014 07:07 PM |
for index, value in ipairs(table) do print(index..":"..value) end
for index, value in pairs(table) do print(index..":"..value) end
for index=1,#table do print(index..":"..table[index]) end
|
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 31 May 2014 07:07 PM |
Same as ipairs except its not in order.
But if you have a table set up like this
local table = {} table["Panda"] = 1
pairs can detect the "Panda" key ipairs cannot |
|
|
| Report Abuse |
|
|
|
| 31 May 2014 07:13 PM |
Sorry for being so stupid but i am learning what is this {}
So if i understand correctly your setting a local variable named table and its value is {}
Then after that i have no idea what you did. |
|
|
| Report Abuse |
|
|
|
| 31 May 2014 07:15 PM |
its a table
its basicly something that can store multiple things
GetChildren() returns a table
MyTable = {"Hi","By","this is the third object!","meh, im #4!"}
print(MyTable[1])
>Hi
print(MyTable[3])
>this is the third object!
print(MyTable[2])
>By
print(MyTable[4])
>meh, im #4!
http://wiki.roblox.com/index.php/Table |
|
|
| Report Abuse |
|
|
|
| 31 May 2014 07:16 PM |
so you could say
T = {p = "Hi"}
print(T.p)
>Hi
or even
T = {} T.p = "Hi"
print(T.p(
>Hi
or
T = {} T["p"] = "Hi" print(T["p"]) |
|
|
| Report Abuse |
|
|
|
| 31 May 2014 07:20 PM |
| Very good reply thank you. |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2014 10:29 AM |
| Sorry to b so nooby what is the key and the value :) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 01 Jun 2014 01:37 PM |
myTable = {"a", "b", "c"};
key -> value 1 -> "a" 2 -> "b" 3 -> "c" values are indexable by: myTable[key] |
|
|
| Report Abuse |
|
|