Colt324
|
  |
| Joined: 19 Aug 2009 |
| Total Posts: 1562 |
|
|
| 01 Aug 2012 01:04 PM |
So it's basically
number = 8
if I wanted to have a table called table8, but 8 could be changed, what would I do to call the table using the variable as the last character of the table name? |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2012 01:06 PM |
table is just the NAME of the table. The only thing you can do is:
local table = {["number"] = 8} print(table["number"])
http://wiki.roblox.com/index.php/User:ElectricBlaze |
|
|
| Report Abuse |
|
|
Colt324
|
  |
| Joined: 19 Aug 2009 |
| Total Posts: 1562 |
|
|
| 01 Aug 2012 01:09 PM |
I'm not asking about assigning a number to a table. Rather, I'm talking about the table name (variable) I need the variable to be called by some textm "table" in my example, and then a number. So if the number I wanted was 8, then the table would be table8 = {} or if the number was 2 table2 = {} |
|
|
| Report Abuse |
|
|
Colt324
|
  |
| Joined: 19 Aug 2009 |
| Total Posts: 1562 |
|
| |
|
L2000
|
  |
| Joined: 03 Apr 2008 |
| Total Posts: 77448 |
|
|
| 01 Aug 2012 01:16 PM |
That wouldn't be possible like that. However, an alternative could be to place it into a table, with the given number being the table:
local myTable = { }; local number = 8; myTable[number] = { }
Which, although not exactly what you'd want, could work in the same way. To find it, instead of saying table8 in the script, you'd say: myTable[8] Or, using the number variable: myTable[number] |
|
|
| Report Abuse |
|
|
su8
|
  |
| Joined: 06 Mar 2009 |
| Total Posts: 6334 |
|
|
| 01 Aug 2012 01:17 PM |
number = 1337 getfenv()["table".. number] = {} |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2012 01:20 PM |
@L2000 - Actually, it is possible. With the getfenv function.
for i = 1, 8 do getfenv()["table" .. i] = {} end
Now you can do:
print(table1) print(table2) print(table3) print(table4) print(table5) print(table6) print(table7) print(table8)
http://wiki.roblox.com/index.php/User:ElectricBlaze |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2012 01:20 PM |
SU8, HOW DARE YOU EARLY POST ME!
http://wiki.roblox.com/index.php/User:ElectricBlaze |
|
|
| Report Abuse |
|
|
Colt324
|
  |
| Joined: 19 Aug 2009 |
| Total Posts: 1562 |
|
|
| 01 Aug 2012 01:21 PM |
Thanks to both su8 and ElectricBlaze.
|
|
|
| Report Abuse |
|
|
|
| 01 Aug 2012 01:21 PM |
No problem. :)
http://wiki.roblox.com/index.php/User:ElectricBlaze |
|
|
| Report Abuse |
|
|
su8
|
  |
| Joined: 06 Mar 2009 |
| Total Posts: 6334 |
|
|
| 01 Aug 2012 01:21 PM |
>SU8, HOW DARE YOU EARLY POST ME!
how dare you late post me? :PPP |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2012 01:23 PM |
nooo cuz latepotsing is normal and we hz to do abnormla stoof!11111111!1111!!!!!!!!!!!!!!!111oneone!111!!!!!!!!!!!!!!11111!!twoeleven!1
http://wiki.roblox.com/index.php/User:ElectricBlaze |
|
|
| Report Abuse |
|
|