|
| 05 Jun 2012 11:23 PM |
00:22:30 - Workspace.TheAI.Think:75: attempt to call field 'insert' (a nil value)
For this line:
table.insert(table, #table+1, val)
Wut?
From Wiki:
"Inserts element value at position pos in table, shifting up other elements to open space, if necessary. The default value for pos is n+1, where n is the length of the table (see §2.5.5), so that a call table.insert(t,x) inserts x at the end of table t."
~Read Between The Squiggles~ |
|
|
| Report Abuse |
|
|
smurf279
|
  |
| Joined: 15 Mar 2010 |
| Total Posts: 6871 |
|
| |
|
|
| 05 Jun 2012 11:25 PM |
Derp :3
~Read Between The Squiggles~ |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 05 Jun 2012 11:26 PM |
You don't have to have the position you know.
tab = {} table.insert(tab,"hi") print(tab[1])
|
|
|
| Report Abuse |
|
|
|
| 05 Jun 2012 11:26 PM |
You probably overwrote table, as the other guy said. Don't use table as a variable.
P.S. Your position is redundant. All you need to do is table.insert(table, val) and it will append it to the end automatically. |
|
|
| Report Abuse |
|
|