Time Spell

Descrição

Conte o tempo da magia na tela apos usar.

Autor:

                -- Configuração

xtela,ytela = 300, 200  -- posição na tela
timemagia = "kai" -- nome da magia laranja ( letra minuscula )
tempo1 = 5000 -- cooldown da magia
tempo2 = 1000 -- tempo da magia ativa
texto = "Nome:" -- Nome que vai aparecer na tela

--

local widget = setupUI([[
Panel
  height: 400
  width: 900
]], g_ui.getRootWidget())

local timespell = g_ui.loadUIFromString([[
Label
  color: white
  background-color: black
  opacity: 0.85
  text-horizontal-auto-resize: true  
]], widget)



macro(1, function()
 if not storage.time.t or storage.time.t < now then
  timespell:setText(texto)
  timespell:setColor('green')
 elseif storage.time.a >= now then
  timespell:setColor('blue')
  timespell:setText(texto .. string.format("%.0f",(storage.time.a-now)/1000).. "s ")
 else  
  timespell:setColor('red')
  timespell:setText(texto .. string.format("%.0f",(storage.time.t-now)/1000).. "s ")
 end
end)

onTalk(function(name, level, mode, text, channelId, pos)
 if name ~= player:getName() then return end
 if text:lower() == timemagia and storage.time.t < now then
  storage.time.t = now + tempo1
  storage.time.a = now + tempo2
 end
end)
 
 
if type(storage.time) ~= 'table' or (storage.time.t - now) > 60000 then
 storage.time = {t = 0, a = 0}
end



timespell:setPosition({y = ytela+40, x =  xtela+10})