Re: Question for tables and variables :3
Posted: Tue Apr 15, 2014 9:03 am
Hm hm. )
![Smile :)](./images/smilies/ms-smile.png)
I write decision before (at screenshot).
I have tables (example):
And i have talbe where i keep all my variables:
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)
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:
And this code work now:
Because MoreSomeTable == table and v.name insert string value and i get name table == MoreSomeTable.MoreSomeTable...
Clearly explained?
Again sorry for my english. ^_^
So close.Ranguna259 wrote:OOH now I see what he wants(maybe)
![Smile :)](./images/smilies/ms-smile.png)
I write decision before (at screenshot).
I have tables (example):
Code: Select all
SomeTable = {}
SomeTable_1 = {}
SomeTable_2 = {}
Code: Select all
MoreSomeTable = {}
MoreSomeTable[1] = {name = "SomeTable"}
MoreSomeTable[2] = {name = "SomeTable_1"}
MoreSomeTable[3] = {name = "SomeTable_2}"
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 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 = {}
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
Clearly explained?
Again sorry for my english. ^_^