Advertisement
Guest User

Biblioteca Window para Transformice api

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