Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is der way to call function by set __metatable field 2 it, & getmetatable return da results of it?

Asked by 4 years ago
Sorry for the bad grammar in the title the site said my title must be between 3 and 100 chars so im here battling just to get a shorter title LOL

My goal

Get getmetatable to return nil by a function I've assigned a __metatable field to.

Code:

local tbl, mt = {}, {
    __metatable = function()
        return nil;
    end
};

setmetatable(tbl, mt);
print(getmetatable(tbl));

Problem

The call getmetatable(tbl) is literally evaluating to the function itself and not calling it,

Is there a way to get this to happen, or would I just have to use some other value? Like an arbitrary table, boolean, ect?? I'd really prefer nil being the output, but if not then oh well.

Btw {__metatable = nil} is NOT going to work since the index won't even be added. Just a note for the inexperienced.

Please answer only if you know what you are talking about. In my past questions, people who don't know what they were talking about answered my questions, and boy did it go bad for them.

Answer this question