mad1231999

Untitled

Jan 25th, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.65 KB | None | 0 0
  1. local gui_server = {
  2.     children = nil;
  3.     width = 100; -- %
  4.     height = 100; -- %
  5.     parent = nil;
  6. }
  7. gui_server.__index = gui_server
  8.  
  9. local function createGUIServer(w, h, c)
  10.     local t = {
  11.         width = w;
  12.         height = h;
  13.     }
  14.     t.children = (c == nil or type(c) ~= "table") and {} or c;
  15.     setmetatable(t, gui_server)
  16.  
  17.     return t
  18. end
  19.  
  20. function gui_server:addChild(c)
  21.  
  22. end
  23.  
  24. function gui_sever:pxSize()
  25.     if self.parent == nil then
  26.         local w, h = term.getSize()
  27.         return math.round(w / 100 * self.width), math.round(h / 100 * self.height)
  28.     end
  29.  
  30.     local w, h = self.parent:pxSize()
  31.  
  32.     return math.round(w / 100 * self.width), math.round(h / 100 * self.height)
  33. end
Advertisement
Add Comment
Please, Sign In to add comment