Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Frame = nil;
- -- let's wrap everything into new scope so it won't pollute the rest of the file
- do
- local metatable, methods = nil, { };
- -- "methods" table is our "__index" table with new functions
- methods.Test = function(self)
- print("test");
- end
- -- this is our constructor
- Frame = function(name, parent)
- -- create frame
- local self = UI.CreateFrame("Frame", name, parent);
- -- if this is our first frame created then setup metatable so it contains both new and original functions
- if (metatable == nil) then
- metatable = {
- __index = setmetatable(methods, { __index = getmetatable(self).__index });
- };
- end
- -- alter frames metatable and return it
- return setmetatable(self, metatable);
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement