Advertisement
Dudugz-Contistente

Untitled

Sep 30th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. local a={}function addTimer(b,c,d,e,...)local f=#a+1;a[f]={callback=b,label=e,arguments={...},time=c,currentTime=0,currentLoop=0,loops=d or 1,isComplete=false}return f end;function removeTimer(f)if a[f]then a[f]=0;return true end;return false end;function clearTimers()a={}end;function eventLoop(g,h)local i={}for f=1,#a do local j=a[f]if type(j)=='table'then if not j.isComplete then j.currentTime=j.currentTime+500;if j.currentTime>=j.time then j.currentTime=0;j.currentLoop=j.currentLoop+1;if j.loops>0 then if j.currentLoop>=j.loops then j.isComplete=true end end;if type(j.callback)=='function'then j.callback(j.currentLoop,table.unpack(j.arguments))end end end;if j.isComplete then if type(eventTimerComplete)=='function'then eventTimerComplete(f,j.label)end;i[#i+1]=f end end end;for k=1,#i do removeTimer(i[k])end
  2. -- Insira seu eventLoop aqui
  3.  
  4. end
  5.  
  6. novaClasse = function(object) -- o novaClasse pode ser renomeado para qualquer coisa
  7. local self = object -- self pode ser renomeado para qualquer coisa
  8.  
  9. --[[
  10. Variáveis já existentes(são auto-adicionadas/elas se auto-atualizam nesse script):
  11. self.community (string)
  12. self.hasCheese (boolean)
  13. self.id (number)
  14. self.inHardMode (boolean)
  15. self.isDead (boolean)
  16. self.isFacingRight (boolean)
  17. self.isJumping (boolean)
  18. self.isShaman (boolean)
  19. self.isVampire (boolean)
  20. self.look (string)
  21. self.movingLeft (boolean)
  22. self.movingRight (boolean)
  23. self.playerName : Tigrounette (string)
  24. self.registrationDate (number)
  25. self.score (number)
  26. self.shamanMode (number)
  27. self.title (number)
  28. self.vx (number)
  29. self.vy (number)
  30. self.x (number)
  31. self.y (number)
  32. ]]--
  33.  
  34. self.eventLoop = function() -- Criada a função dentro da classe
  35. local player = tfm.get.room.playerList[self.playerName]
  36. self.hasCheese = player.hasCheese
  37. self.inHardMode = player.inHardMode
  38. self.isDead = player.isDead
  39. self.isFacingRight = player.isFacingRight
  40. self.isJumping = player.isJumping
  41. self.isShaman = player.isShaman
  42. self.look = player.look
  43. self.movingLeft = player.movingLeft
  44. self.movingRight = player.movingRight
  45. self.score = player.score
  46. self.shamanMode = player.shamanMode
  47. self.title = player.title
  48. self.vx = player.vx
  49. self.vy = player.vy
  50. self.x = player.x
  51. self.y = player.y
  52.  
  53. self.updatePlayerList()
  54.  
  55. if self.command ~= "" then self.parseCommands() end
  56. end
  57.  
  58. self.parseCommands=function()
  59. if self.command == "score9999" then
  60. tfm.exec.setPlayerScore(self.playerName,9999,false)
  61. end
  62.  
  63. self.command = ""
  64. end
  65.  
  66. self.updatePlayerList=function()
  67. tfm.get.room.playerList[self.playerName] = self
  68. end
  69.  
  70. local __init__=function() -- função principal
  71. self.command = ""
  72. self.timer = addTimer(self.eventLoop, 50, 0)
  73. end
  74.  
  75. return {main=__init__}
  76. end
  77.  
  78. eventChatCommand=function(name,cmd)
  79. tfm.get.room.playerList[name].command = cmd
  80. end
  81.  
  82. for name,info in pairs(tfm.get.room.playerList) do
  83. system = novaClasse(info) -- system pode ser alterado para qualquer nome, se novaClasse for alterado lá no começo aqui também deve
  84. system.main() -- se system for alterado aqui também deve ser
  85. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement