Advertisement
Dramiel

RIFT Extending frames

Nov 22nd, 2011
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.83 KB | None | 0 0
  1. local Frame = nil;
  2. -- let's wrap everything into new scope so it won't pollute the rest of the file
  3. do
  4.     local metatable, methods = nil, { };
  5.  
  6.     -- "methods" table is our "__index" table with new functions
  7.     methods.Test = function(self)
  8.         print("test");
  9.     end
  10.  
  11.     -- this is our constructor
  12.     Frame = function(name, parent)
  13.         -- create frame
  14.         local self = UI.CreateFrame("Frame", name, parent);
  15.  
  16.         -- if this is our first frame created then setup metatable so it contains both new and original functions
  17.         if (metatable == nil) then
  18.             metatable = {
  19.                 __index = setmetatable(methods, { __index = getmetatable(self).__index });
  20.             };
  21.         end
  22.  
  23.         -- alter frames metatable and return it
  24.         return setmetatable(self, metatable);
  25.     end
  26. end
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement