Topic: Arrays

Hey! Can you show me how to use arrays? As far as I understand:

A = {}

This will give me as much A0, A1, A2, A3, A4 as I need but what I don't understand is when you want separate HP values and stuff like that.

Say

A = {hpval}

Do I then write A.hpval = 1 when I want the first A's hpval to be 1?

Thanks

Re: Arrays

a classic array works like that :

A = {12, 4, 3, 2, 8}

in lua indices starts at 1 :

A[1] is 12
A[2] is 4
etc

Re: Arrays

So you cant have multiple A's like A = {1, 2, 3, 4, 5}

And A[1] = A1 ?

Re: Arrays

I don't understand what you mean, what is A1 ?

Re: Arrays

Oh nevermind.

I mean tables. How does tables work?

Can you assign a name to a table like

A = {}

And have A1, A2, A3 and so on? I'm trying to make NPC's and they are hard to code if I need to make everyone in code.

Re: Arrays

with arrays, or tables, you use indices or names :

A["x"] = 10
similar to : A.x = 10

or :

A[1] = 2
A[2] = 3
etc

Re: Arrays

Cool, then. A = {timer = 0, rotate = 0, move = 0}

So A.timer will be 0 and rotate 0?

Re: Arrays

yes i think