Miro034
|
  |
| Joined: 07 Oct 2009 |
| Total Posts: 6568 |
|
|
| 31 Mar 2015 07:18 PM |
Hi, I'm extremely used to python and never programmed using Lua in months. How would you want to index particular elements in a table? Would it be like this?
table = {"hello","blah","blah2"} print(table[0])
and like this?
table.insert(table[0],"table") print(table[0]) |
|
|
| Report Abuse |
|
|
amanda
|
  |
| Joined: 21 Nov 2006 |
| Total Posts: 5925 |
|
|
| 31 Mar 2015 07:20 PM |
Lua indices start at 1.
table.insert(table, [pos,] value) |
|
|
| Report Abuse |
|
|
amanda
|
  |
| Joined: 21 Nov 2006 |
| Total Posts: 5925 |
|
|
| 31 Mar 2015 07:21 PM |
| table.insert(table, 1, 'bob') |
|
|
| Report Abuse |
|
|
|
| 31 Mar 2015 07:22 PM |
table = {"hello","blah","blah2"} print(table[1]) -- lua tables start at 1
and like this?
table.insert(table,"table") -- that adds it to the end of the table table[1] = "table" -- i think thats how u replace something in a table print(table[1]) |
|
|
| Report Abuse |
|
|
|
| 31 Mar 2015 07:23 PM |
oh yea what amanda said with table.insert(table, 1, 'table') is what u should use to change something in a table
i forgot about that |
|
|
| Report Abuse |
|
|
Miro034
|
  |
| Joined: 07 Oct 2009 |
| Total Posts: 6568 |
|
| |
|