Advertisement
Dudugz-Contistente

Untitled

Oct 5th, 2017
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. data={}
  2.  
  3. day_cicle = function(object)
  4. local this = object
  5.  
  6. local __init__=function()
  7. this.id = os.time();
  8. this.time = os.time();
  9. this.elapsed = os.time();
  10.  
  11. this.dark = 120
  12.  
  13. this.next = "night"
  14. end
  15.  
  16. this.eventLoop=function()
  17. if this.time < os.time()-120000 and this.elapsed < os.time()-12000 and this.dark > 75 and this.next == "night" then
  18. this.dark = this.dark - 5
  19. this.elapsed=os.time();
  20. if this.dark == 75 then
  21. this.time=os.time();
  22. this.next = "day"
  23. end
  24. end
  25.  
  26. if this.time < os.time()-120000 and this.elapsed < os.time()-6000 and this.dark < 120 and this.next == "day" then
  27. this.dark = this.dark + 5
  28. this.elapsed=os.time();
  29. if this.dark == 120 then
  30. this.time=os.time();
  31. this.next = "night"
  32. end
  33. end
  34.  
  35. ui.addTextArea(this.id,"",this.username,-300,-200,9999,9999,1,1,this.dark,true)
  36. end
  37.  
  38. return {main=__init__,loop=this.eventLoop}
  39. end
  40.  
  41. function eventLoop()
  42. for all in pairs(tfm.get.room.playerList) do
  43. if data[all] then
  44. data[all].loop()
  45. end
  46. end
  47. end
  48.  
  49. function eventNewPlayer(name)
  50. data[name]=day_cicle({username=name})
  51. data[name].main()
  52. end
  53.  
  54. table.foreach(tfm.get.room.playerList,eventNewPlayer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement