'LinKin Posted November 15, 2013 Share Posted November 15, 2013 Hello, I'd like to know how does a table look like in LUA for MTA:SA When you define; local table = { } How does it look like? Like a vector? |_| |_| |_| |_| |_| |_| Or like a Matrice? |_||_||_||_| |_||_||_||_| |_||_||_||_| |_||_||_||_| |_||_||_||_| |_||_||_||_| The thing is, I want to have something like a matrice, where I can set a name(string) as one column and a number(int) as other column Link to comment
tosfera Posted November 15, 2013 Share Posted November 15, 2013 if you create a empty table, it will look... empty. Just like the vector you showed us. Though, your first value decides what your table will look like. If you're adding a new table in it, it will be a matrice; local table = {} table.insert ( table, { "somename", 17 } ); Link to comment
'LinKin Posted November 15, 2013 Author Share Posted November 15, 2013 if you create a empty table, it will look... empty. Just like the vector you showed us. Though, your first value decides what your table will look like. If you're adding a new table in it, it will be a matrice; local table = {} table.insert ( table, { "somename", 17 } ); Thanks mate, But now, how can I have access to the 2nd value of that table? Like; table[somename]=2. Would it work and change the 17 for the 2? Link to comment
tosfera Posted November 15, 2013 Share Posted November 15, 2013 If you would be using a vector as a table it would be as simple as this; table[1] = "another name" Since you aint using that one, you've to say which row, which column. Just like a database; table[1][1] = "another name"; table[1][2] = 99; That would change the first row to 'another name' and 99. Link to comment
'LinKin Posted November 15, 2013 Author Share Posted November 15, 2013 Thanks a lot mate! This is what I was looking after. Link to comment
tosfera Posted November 15, 2013 Share Posted November 15, 2013 Haha no problem, goodluck! 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