Bolodefchoco_LUAXML

[Script] Age on other planets

Jan 16th, 2016
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.57 KB | None | 0 0
  1. --Creator: Bolodefchoco
  2. --Made in: 16/01/2016
  3. --Last update: 25/05/2016
  4. --[[ Notes:
  5.     Does:
  6.         Descubra sua idade em outros planetas!
  7.     Commands:
  8.         !
  9.             dd/mm/yyyy --> Dia de nascimento / Mês de nascimento / Ano de nascimento
  10. ]]--
  11.  
  12. mice={}
  13. eventNewPlayer=function(n)
  14.     if not mice[n] then
  15.         mice[n]={
  16.             day=-1,
  17.             month=-1,
  18.             year=-1,
  19.         }
  20.     end
  21. end
  22. table.foreach(tfm.get.room.playerList,eventNewPlayer)
  23.  
  24. age=function(day,month,year)
  25.     if type(day) == "string" then
  26.         day,month,year = day:match("(%d+)/(%d+)/(%d+)")
  27.     end
  28.     day,month,year = tonumber(day),tonumber(month),tonumber(year)
  29.     local cDay,cMonth,cYear = tonumber(os.date("%d")),tonumber(os.date("%m")),tonumber(os.date("%Y"))
  30.     if year <= cYear then
  31.         if month < cMonth then
  32.             return cYear-year
  33.         end
  34.         if month == cMonth then
  35.             if day <= cDay then
  36.                 return cYear-year
  37.             else
  38.                 return cYear-year-1
  39.             end
  40.         end
  41.         if month > cMonth then
  42.             return cYear-year-1
  43.         end
  44.     end
  45.     return 0
  46. end
  47.  
  48. eventChatCommand=function(n,c)
  49.     local d={}
  50.     for v in c:gmatch('[^/]+') do
  51.         table.insert(d,v)
  52.     end
  53.     mice[n].day,mice[n].month,mice[n].year = tonumber(d[1]),tonumber(d[2]),tonumber(d[3])
  54.     local data = {{"Mercury",0.241},{"Venus",0.615},{"Earth",1},{"Mars",1.881},{"Jupiter",11.86},{"Saturn",29.46},{"Uranus",84.01},{"Neptune",164.8},{"Pluto",248.6}}
  55.     local age = age(mice[n].day,mice[n].month,mice[n].year)
  56.     local text = ""
  57.     for i = 1,#data do
  58.         text = text .. "<J>"..data[i][1].." <BL>- <PT>"..age/data[i][2].." years old\n"
  59.     end
  60.     ui.addTextArea(0,"<font size='22'>You are ...</font>\n"..text,n)
  61. end
Advertisement
Add Comment
Please, Sign In to add comment