Dynamically assigned table variables?

后端 未结 1 1549
無奈伤痛
無奈伤痛 2021-01-21 06:42

Writing a function in Lua, which creates two tables. I want the tables to be assigned to the value name with an x added, and one with a y added. For example if name was line, it

相关标签:
1条回答
  • 2021-01-21 06:50

    If you want these in the global name space you would use

    _G[name..'x']={}
    _G[name..'y']={}
    

    For a module you'd use _M in place of _G.

    0 讨论(0)
提交回复
热议问题