Page 2 of 2

Re: Question for tables and variables :3

Posted: Tue Apr 15, 2014 9:03 am
by Volgoza
Hm hm. )
Ranguna259 wrote:OOH now I see what he wants :crazy: (maybe)
So close. :)

I write decision before (at screenshot).
I have tables (example):

Code: Select all

SomeTable = {}
SomeTable_1 = {}
SomeTable_2 = {}
And i have talbe where i keep all my variables:

Code: Select all

MoreSomeTable = {}
MoreSomeTable[1] = {name = "SomeTable"}
MoreSomeTable[2] = {name = "SomeTable_1"}
MoreSomeTable[3] = {name = "SomeTable_2}"
And i have code, where i move object with coursor mouse and when MouseX and MouseY at coordinates objects of MoreSomeTable i need add value in table. Table names as MoreSomeTable[1].name ...
See? ))

Next: Assume that I have add in table value as i clicked. (Example)

Code: Select all

function love.mousepressed(x, y, button)
if button == "l" then
for i,v in ipairs (MoreSomeTable) do 
table.insert (v.name, 1)
end
end
end
But i can't write v.name, because v.name in this case == "string".

But i can create not 3 tables SomeTable... but create table SomeTable = {} and 3 tables in this table:

Code: Select all

SomeTable = {}
SomeTable.SomeTable = {}
SomeTable.SomeTable_1 = {}
SomeTable.SomeTable_2 = {}
And this code work now:

Code: Select all

function love.mousepressed(x, y, button)
if button == "l" then
for i,v in ipairs (MoreSomeTable) do 
table.insert (MoreSomeTable[v.name], 1)
end
end
end
Because MoreSomeTable == table and v.name insert string value and i get name table == MoreSomeTable.MoreSomeTable...

Clearly explained?
Again sorry for my english. ^_^

Re: Question for tables and variables :3

Posted: Tue Apr 15, 2014 11:40 am
by Ranguna259
Well.. you fixed the problem, all you need to do is to change the string into a table value

Re: Question for tables and variables :3

Posted: Tue Apr 15, 2014 1:16 pm
by Volgoza
Yes. I did it later :D

But my example sooooo good and extraordinary... and through the ass :awesome: :awesome: