table.insert position

Post Reply
solarkactus
Posts: 20
Joined: Sat Jan 29, 2011 12:05 am

table.insert position

Post 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?

Iocun
Posts: 174
Joined: Wed Dec 02, 2009 1:45 am

Re: table.insert position

Post by Iocun »

In a key-value pair table, simple do: guys[nickname] = name

solarkactus
Posts: 20
Joined: Sat Jan 29, 2011 12:05 am

Re: table.insert position

Post by solarkactus »

Works, thanks Iocun. : ) I feel somewhat like an idiot haha.

Post Reply