Basically, I want to do something where I have table0, table1, table2, etc.
I want to refer to those tables by getting a value and matching that with the rest of the table name. However, it seems that table..X doesn't work. How do I correctly address that table?
Stupid Lua Question - Concatenation of Table Name
Moderator: Moderators
Re: Stupid Lua Question - Concatenation of Table Name
Seriously? You can't just put them in another table? But okay, as long as they aren't local:
real_G = getfenv()
table = real_G['table'..X]
I worry that I shouldn't be telling you this.
real_G = getfenv()
table = real_G['table'..X]
I worry that I shouldn't be telling you this.
Re: Stupid Lua Question - Concatenation of Table Name
Meh, I'm just trying to avoid a lot of very tedious copy-pasta, basically. Oops, I meant, "oh, my super-secret project requires that I need this". I didn't realize this was non-trivial, tbh, I just figured I was a little slow this evening.
Can't I just get the current index for the table, by getting the [0] value? Or is what you're showing me the only way to make it work? I don't really need this stuff to be global.
Can't I just get the current index for the table, by getting the [0] value? Or is what you're showing me the only way to make it work? I don't really need this stuff to be global.
Re: Stupid Lua Question - Concatenation of Table Name
And you cant do that by making a big table with your little tables in it? supertable = {[1] = {}}Argh wrote:Meh, I'm just trying to avoid a lot of very tedious copy-pasta, basically.
That... physically hurt.Argh wrote:Can't I just get the current index for the table, by getting the [0] value?
The table variable IS the index, you crazy man.
Re: Stupid Lua Question - Concatenation of Table Name

Re: Stupid Lua Question - Concatenation of Table Name
<pant, pant>
Ok, multiple tables are finally working. Moving on, to the easy part...
Ok, multiple tables are finally working. Moving on, to the easy part...