-- pretend that there is a __metatable field given to a table
setmetatable(_G, {__index = {None="No indexes"}})< br /> - error: (the string given to the __metatable metamethod)
What I am trying to do here is to escape the __metatable field and just allow myself to set metamethod on _G, which already has one.
I know this is impossible, but I want to ask if there is still a chance to bypass it?
The focus of __metatable is protection. The debugging library bypasses this protection (and others), and of course it should be used with caution.
I want to know if there is a way to escape __metatable meta method. I know there is no one, but I am trying to do something like this, but obviously __metatable will prevent this from happening:
-- pretend that there is a __metatable field given to a table
setmetatable(_G, {__index = {None="No indexes"}})
- error: (the string given to the __metatable metamethod) pre>What I am trying to do here is to escape the __metatable field, and just allow myself to set metatable on _G, it already has one.
I know this is impossible to do, but I want to ask Is there still a chance to bypass it?The only way to do this from Lua is to use debug.setmetatable.
The focus of __metatable is to protect. Debug library Bypass this protection (and others), and of course should be used with caution.