Cassandra Posted April 5, 2012 Share Posted April 5, 2012 Is it possible to create multi dimensional tables on LUA? If yes, can you provide me an example creation? Link to comment
Castillo Posted April 5, 2012 Share Posted April 5, 2012 I'm not sure if this is what do you mean: items = { { [ "category" ] = "Weapons", [ "name" ] = "M4", [ "price" ] = 1000, [ "quantity" ] = 500 }, { [ "category" ] = "Skills", [ "name" ] = "M4 Skill", [ "price" ] = 2000, [ "quantity" ] = 1000 } } Link to comment
drk Posted April 5, 2012 Share Posted April 5, 2012 (edited) This? local cTable = { instance = { [1] = 'Crazy'; } } outputChatBox ( cTable.instance[1] ) Basically, is what Solidsnake said Edited April 5, 2012 by Guest Link to comment
Cassandra Posted April 5, 2012 Author Share Posted April 5, 2012 I'm not sure if this is what do you mean: items = { { [ "category" ] = "Weapons", [ "name" ] = "M4", [ "price" ] = 1000, [ "quantity" ] = 500 }, { [ "category" ] = "Skills", [ "name" ] = "M4 Skill", [ "price" ] = 2000, [ "quantity" ] = 1000 } } That's singular dimension. I want something like this. local items = { { name = "Something" weight = 20 height = 20 }, { playerid = 0 } } items[name][1] = "something" -- The first dimension is the info, the second dimension is the playerid Link to comment
Kenix Posted April 5, 2012 Share Posted April 5, 2012 Both the codes wrong. local t = { tSecond = { nValue = 1; } } print( t.tSecond.nValue ) --1 ------- or ------------------------- print( t['tSecond']['nValue'] ) -- 1 -- ------- or ------------------------- print( t.tSecond['nValue'] ) -- 1 -- ------- or ------------------------- -- Some codes print( t['tSecond'].nValue ) -- 1 Link to comment
Cassandra Posted April 5, 2012 Author Share Posted April 5, 2012 Both the codes wrong. local t = { tSecond = { nValue = 1; } } print( t.tSecond.nValue ) --1 ------- or ------------------------- print( t['tSecond']['nValue'] ) -- 1 -- ------- or ------------------------- print( t.tSecond['nValue'] ) -- 1 -- ------- or ------------------------- -- Some codes print( t['tSecond'].nValue ) -- 1 Thanks but I have already found a way. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now