Table issues

Hi there, i’ve got many problem to understand how table works.
I need to develop an app in order to purchase items.
Of course the “qualities” of the items are concatenates, for example:

what – price – quantity – subTotal

pen ----- 1 ----- 2 --------- 2
rubber – 1,5 ---- 3 -------- 4,5

how can i manage all that stuff in a table?
it should be simple… :frowning:

is it correct?

local q  
local sub  
local table = {}  
table[1] = {what = "pen", price = 1, quantity = q, subTotal = sub}  
table[2] = {what = "rubber", price = 1.5, quantity = q, subTotal = sub}  

how can i use and manage my variables??
Please don’t tell me to read the docs cause i can’t understand.

Thanx guys… [import]uid: 30837 topic_id: 13116 reply_id: 313116[/import]

This will work fine, however quantity and subTotal will return as nil because you haven’t stated what q and sub are yet.

If you put in, for example;

[lua]print (table[2].price)[/lua]

It will return 1.5 as you intended.

Peach [import]uid: 52491 topic_id: 13116 reply_id: 48180[/import]

PERFECT!
Thanx :slight_smile: [import]uid: 30837 topic_id: 13116 reply_id: 48186[/import]