Advertisement
Guest User

Biblioteca Window para Transformice api

a guest
Apr 23rd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.23 KB | None | 0 0
  1. window = {
  2.   w = {},
  3.   open = function(p, id, ...)
  4.     local w = window.w
  5.     if p and id then
  6.       if w[id] then
  7.         w[id].player[p] = {}
  8.         w[id].player[p].fixed = w[id].player[p].fixed or w[id].open(p, id, ...)
  9.         w[id].player[p].dynamic = w[id].player[p].dynamic or (w[id].update and w[id].update(p, id, ...))
  10.       end
  11.     end
  12.   end,
  13.   close = function(p, id)
  14.     local w = window.w
  15.     if p and id then
  16.       if w[id] then
  17.         if w[id].player[p] then
  18.           if w[id].player[p].fixed then
  19.             for i, v in pairs(w[id].player[p].fixed.img or {}) do
  20.               tfm.exec.removeImage(v)
  21.             end
  22.             for i, v in pairs(w[id].player[p].fixed.txt or {}) do
  23.               ui.removeTextArea(v, p)
  24.             end
  25.           end
  26.           if w[id].player[p].dynamic then
  27.             for i, v in pairs(w[id].player[p].dynamic.img or {}) do
  28.               tfm.exec.removeImage(v)
  29.             end
  30.             for i, v in pairs(w[id].player[p].dynamic.txt or {}) do
  31.               ui.removeTextArea(v, p)
  32.             end
  33.           end
  34.           w[id].player[p] = nil
  35.         end
  36.       end
  37.     end
  38.   end,
  39.   update = function(p, id, ...)
  40.     local w = window.w
  41.     if p and id then
  42.       if w[id] and w[id].player[p] then
  43.         if w[id].update then
  44.           if w[id].player[p].dynamic then
  45.             for i, v in pairs(w[id].player[p].dynamic.img or {}) do
  46.               tfm.exec.removeImage(v)
  47.             end
  48.             for i, v in pairs(w[id].player[p].dynamic.txt or {}) do
  49.               ui.removeTextArea(v, p)
  50.             end
  51.             w[id].player[p].dynamic = nil
  52.           end
  53.          w[id].player[p].dynamic = w[id].update(p, id, ...)
  54.         else
  55.           window.close(p, id)
  56.           window.open(p, id, ...)
  57.         end
  58.       end
  59.     end
  60.   end,
  61.   isOpened = function(p, id)
  62.     local w = window.w
  63.     return w[id] and w[id].player[p] and true or false
  64.   end,
  65.   create = function(id, func, func2)
  66.     local w = window.w
  67.     if w[id] then
  68.       for i, v in pairs(w[id].player) do
  69.         window.close(i, id)
  70.       end
  71.     end
  72.     if id and func then
  73.       w[id] = {
  74.         open = func,
  75.         update = func2,
  76.         player = {}
  77.       }
  78.     end
  79.   end
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement