Bolodefchoco_LUAXML

[Script] Conversor de temperaturas (°C,°F,K)

Jan 10th, 2016
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.75 KB | None | 0 0
  1. --Creator: Bolodefchoco
  2. --Made in: 10/01/2016
  3. --Last update: 25/05/2016
  4. --[[ Notes:
  5.     Does:
  6.         Realiza a transformação de um grau para outro (Celcius, Fahrenheit, Kelvin)
  7. ]]--
  8.  
  9. adm = "Bolodefchoco" ----<---- Seu Nickname
  10.  
  11. local from,to
  12.  
  13. local id = 0
  14. spawn=function(i)
  15.     for x = i,i do
  16.         for k,v in next,{i<2 and "From" or "To","Celcius","Fahrenheit","Kelvin"} do
  17.             id = id + 1
  18.             if from ~= v:sub(1,1):lower() then
  19.                 local t = i==1 and "_" or "@"
  20.                 ui.addTextArea(id,("<p align='center'><font size='14'><%s><a href='event:%s'>%s"):format(k==1 and "J" or "VP",t..v:sub(1,1):lower(),k==1 and "</a>"..v or v),adm,(i*150) - 135,k*40,100,25)
  21.             end
  22.         end
  23.     end
  24. end
  25.  
  26. eventTextAreaCallback=function(i,n,c)
  27.     if c ~= "new" then
  28.         if c:sub(1,1) == "_" and not from then
  29.             from = c:sub(2)
  30.             spawn(2)
  31.         end
  32.         if c:sub(1,1) == "@" and not to then
  33.             to = c:sub(2)
  34.         end
  35.         if to and from then
  36.             ui.addPopup(0,2,"Number below",n,320,50,100)
  37.         end
  38.     else
  39.         from,to = nil,nil
  40.         for i = -1,id do ui.removeTextArea(i,n) end
  41.         spawn(1)
  42.     end
  43. end
  44.  
  45. eventPopupAnswer=function(i,n,a)
  46.     local temp={}
  47.     temp.ck = function(x)
  48.         return tostring(math.floor(x) + 273).." K"
  49.     end
  50.     temp.fk = function(x)
  51.         return tostring(x-32/1.8 + 273.15).." K"
  52.     end
  53.     temp.cf = function(x)
  54.         return tostring(x*1.8+32).." °F"
  55.     end
  56.     temp.kf = function(x)
  57.         return tostring((x-273.15)*1.8+32).." °F"
  58.     end
  59.     temp.fc = function(x)
  60.         return tostring((x-32)/1.8).." °C"
  61.     end
  62.     temp.kc = function(x)
  63.         return tostring(x - 273.15).." °C"
  64.     end
  65.     ui.addTextArea(0,"<p align='center'><font size='15'><PT>"..temp[from..to](tonumber(a)),n,320,50,nil,30)
  66.     ui.addTextArea(-1,"<p align='center'><font size='14'><R><a href='event:new'>New transformation",n,320,90,50,20)
  67. end
  68.  
  69. spawn(1)
Add Comment
Please, Sign In to add comment