Jump to content

Tables


'LinKin

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...