Advertisement
Patosho

msgBoxes

Dec 18th, 2015
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.06 KB | None | 0 0
  1. local ui_msgbox_time = 8000
  2. local ui_msgbox_max = 5
  3. local ui_msgbox_x,ui_msgbox_y,ui_msgbox_w,ui_msgbox_h,ui_msgbox_dy = 100,50,600,20,35
  4. local ui_msgbox_c,ui_msgbox_bc,ui_msgbox_da = nil,nil,0.2
  5. local ui_msgbox_messages = {}
  6.  
  7. function showMsg(msg, tgt)
  8.     local box,j
  9.     if ui_msgbox_messages[ui_msgbox_max] then ui_msgbox_messages[ui_msgbox_max] = nil end
  10.     for i=#ui_msgbox_messages+1,1,-1 do
  11.         if i==1 then
  12.             ui_msgbox_messages[i] = {msg=msg, ts=os.time()}
  13.         else
  14.             ui_msgbox_messages[i] = ui_msgbox_messages[i-1]
  15.         end
  16.         j = i - 1
  17.         ui.addTextArea(i, ui_msgbox_messages[i].msg, tgt, ui_msgbox_x, ui_msgbox_y + j*ui_msgbox_dy, ui_msgbox_w, ui_msgbox_h, ui_msgbox_c, ui_msgbox_bc, 1 - j*ui_msgbox_da, true)
  18.     end
  19. end
  20.  
  21. function eventLoop(t,tr)
  22.     for i=1,ui_msgbox_max do
  23.         local m = ui_msgbox_messages[i]
  24.         if m and m.ts + ui_msgbox_time < os.time() then
  25.             ui_msgbox_messages[i] = nil
  26.             ui.removeTextArea(i, nil)
  27.         end
  28.     end
  29. end
  30.  
  31. function eventChatCommand(name, com)
  32.     if com:sub(1,3) == "msg" then
  33.         showMsg("<V>["..name.."]<N> "..com:sub(5,60))
  34.     end
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement