Page 1 of 1

table.insert position

Posted: Sun Mar 06, 2011 10:51 am
by solarkactus
I want a function which adds a key (a string!) and value to a table.

Something like:
function addnewguy(nickname,name)
table.insert(guys,nickname,name)
end

Except the above doesn't seem to work.
The "pos" in table.insert (table, [pos,] value) has to be a number value i guess.

Is there another way I can do it?

Re: table.insert position

Posted: Sun Mar 06, 2011 12:18 pm
by Iocun
In a key-value pair table, simple do: guys[nickname] = name

Re: table.insert position

Posted: Sun Mar 06, 2011 7:01 pm
by solarkactus
Works, thanks Iocun. : ) I feel somewhat like an idiot haha.