--Table Int--
local Apps = {
[1] = {name = "NPaintPro", author = "Nitrogenfingers", handler = function() end},
[2] = {name = "FireWolf", author = "Gravityscore", handler = function() end},
[3] = {name = "Taco", author = "Da404lewZer", handler = function() end},
}
--Testing add Icon to Table--
local tArgs = {...}
table.insert(Apps,[#Apps+1] = {name = tArgs[1], author = tArgs[2], handler = function() tArgs[3] end})
[Lua][Question] Table.insert
Started by darkroom, Jan 03 2013 05:57 AM
1 reply to this topic
#1
Posted 03 January 2013 - 05:57 AM
I am making my first OS! Or some kinda file manger thingy... anyway I am basing it all in tables that store information about the icons in a large object table problem is I have no idea how to use table.insert and I need that function
anyway this is just a little of the code. Thanks for your time 
#2
Posted 03 January 2013 - 06:32 AM
Take out the "[#Apps + 1] = " part; it will automatically place the new entry at the end of the table. You only need to specify a new index if you want it elsewhere than the end of the table. The position (when necessary) is specified as an argument. To insert a new value at the beginning of a table, for example:
table.insert(tab, 1, "new value")
table.insert(tab, 1, "new value")
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











