Code: Select all
helper.mods.mod_1
helper.mods.mod_2
helper.mods.mod_3
helper.mods.mod_n
One part of the helper mod is a function to convert this “semi-global” (because within the helper mod’s global table) individual mod’s tables into “real” global tables if the individual mod’s authors want that. I do this for not polluting the global namespace if not wanted/needed.
As I learned via research Lua maintains the global variables in the table _G. This allows adding “variable variables” like so:
Code: Select all
for name,value in pairs(helper.mods) do
_G[name] = value
end
The only problem is that a warning gets triggered for every time I do this _G assignment.
Code: Select all
2018-05-17 17:59:45: WARNING[Main]: Assignment to undeclared global "[...]" inside a function at [...].
So how to get rid of this error message? Is there a proper way to register a global variable in Minetest without knowing the variables name but only having a local variable holding the name of the to-be-created global variable?