Does anyone know how to rename a table name with a string that you define earlier in a script?
local tab1={}
local myString =“mystrtable”
–here this string will be changed in script with other string so I want to have a dynamic table name.
–[[
how to rename tab1 with the value of myString ???
I don’t think you can rename a table after you have created it, if you can, someone will correct me.
I would suggest creating a new table with the appropriate name, copying the data from the original to the new table, then setting the original table to nil, so it gets GC’d. [import]uid: 5317 topic_id: 12079 reply_id: 44141[/import]
here, the secret is “loadstring()”… “assert” is used for catching errors if loadstring fails (ie. syntax errors) according to lua book… [import]uid: 46529 topic_id: 12079 reply_id: 44313[/import]