Advertisement
Novohp

Harvest Apple

Jul 23rd, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.78 KB | None | 0 0
  1. -----------------------------
  2. -- @Alguns valores de armazenamento e dados.
  3. -- @Desabilita algumas funções do jogo.
  4. --@ Auto shaman, Auto new game, Auto time left, Consumiveis, Auto morte, afk morte, Auto score.
  5. -----------------------------  
  6. for _, v in next, {'AutoShaman', 'AutoNewGame', 'AutoTimeLeft', 'PhysicalConsumables', 'AfkDeath', 'MortCommand', 'AutoScore'} do
  7.     tfm.exec['disable' .. v]()
  8. end
  9. -----------------------------
  10. --@ Algumas variaveis
  11. -----------------------------
  12. newData = {} -- Armazena algums dados importantes do jogo.
  13. deleteObject = {} -- Para deletar objetos shamam após determinado tempo.
  14. tempo = os.time() -- Para ausilio do time.
  15. p = 0 -- Jogadores na sala.
  16. proom = 0 -- ↑
  17. -- @Inicio do jogo
  18. StartTime=false -- Iniciar o tempo.
  19. startGame=false -- Iniciar o jogo.
  20. -----------------------------
  21. --@ Evento acontece quando um jogador entra na sala.
  22. -----------------------------
  23. function eventNewPlayer(name)
  24.     proom=proom+1
  25.         newData[name] = {
  26.             Team = "",
  27.             XP = 0,
  28.             Level = 0,
  29.             Life = 3,
  30.             lang = "",
  31.             Apple = 0,
  32.             tempo = os.time(),
  33.             ingredients = 0,
  34.             bonus = 0,
  35.     }
  36.     TextAreaApple(name)
  37. ---------------------------------
  38. -- @Quantia de players necessarias para iniciar a partida.
  39. -- @Dar incio ao jogo/ sai do lobby
  40. ---------------------------------
  41. if proom < 2 then
  42.     ui.setMapName("<CE>Precisa de mais jogadores para começar o jogo</CE>")
  43.     lobby()
  44. end
  45. if (not startGame) then
  46.     if (proom >= 1) then
  47.         tempo = 20
  48.         StartTime=true
  49.         end
  50.     end
  51. -----------------------------
  52. -- @System que define quem ganha a partida
  53. -----------------------------
  54. function eventLoop(currentTime,timeRemaining)
  55.     for _,obj in ipairs(deleteObject) do
  56.         if obj.time < os.time()-4000 then
  57.             tfm.exec.removeObject(obj.id)
  58.             table.remove(deleteObject,_)
  59.         end
  60.     end
  61.     if (startGame) then
  62.         tfm.exec.addShamanObject(39, math.random(7, 697),0,0,0,true)
  63.         tfm.exec.addShamanObject(39, math.random(4, 700),0,0,0,true)
  64.     end    
  65.     if timeRemaining <= 15000 then
  66.         if newData[name].Apple > 3 then
  67.             tfm.exec.giveCheese(name)
  68.             tfm.exec.playerVictory(name)
  69.             newData[name].Apple = 0
  70.             newData[name].bonus = newData[name].bonus + 10
  71.             newData[name].ingredients = newData[name].ingredients + newData[name].Apple
  72.             lobby()
  73.         else
  74.             tfm.exec.killPlayer(name)
  75.             newData[name].bonus = newData[name].bonus + 5
  76.             newData[name].ingredients = newData[name].ingredients + newData[name].Apple
  77.         end
  78.     end        
  79.     if (StartTime) then
  80.         if (tempo > 0) then
  81.             tempo = (tempo - 0.5)
  82.             if (not tostring(tempo):find('.5')) then
  83.                 ui.setMapName("<CE>A partida começa em "..(tempo + 1).." segundos.</CE>")
  84.             end
  85.         elseif (not startGame) then
  86.             StartTime = false
  87.             startGame = true
  88.             round()        
  89.      tfm.exec.setGameTime(100)  
  90.             end
  91.         end
  92.     end    
  93. end -- End do eventNew player.
  94. ---------------------------------
  95. -- @ Evento acontece quando um novo jogo começa.
  96. ---------------------------------      
  97. function eventNewGame()
  98.     for p,n in pairs(tfm.get.room.playerList) do
  99.         keyEvent(p)
  100.         newData[p].Apple = 0
  101.         tfm.exec.setPlayerScore(p,newData[p].Apple)
  102.         TextAreaApple(p)
  103.     end
  104. end
  105. ---------------------------------
  106. -- @ TextArea das maçãs coletadas.
  107. ---------------------------------
  108. function TextAreaApple(name)
  109.     ui.addTextArea(0, "<font size='25'><B><VP>"..newData[name].Apple.."</font>", name,  40, 363, 97, 30, 0x324650, 0x000000, 0, true)
  110. end
  111. ---------------------------------
  112. -- @ Mapa.
  113. ---------------------------------
  114. function round()
  115.     tabela={"x_transformice/x_evt/x_evt_15/ngzldsop/map-paques-fond.jpg","x_transformice/x_evt/x_evt_01/kjneb75/map-nouvel-an.jpg","x_transformice/x_evt/rs4otmym/epiphanie.jpg","x_transformice/x_evt/x_evt_05/yelfrdge/fond.jpg","x_transformice/x_evt/x_evt_08/zenlksgd/fond.jpg"}
  116.     tfm.exec.newGame('<C><P d="x_chamane/i_003.png,5,363" D="'..tabela[math.random(#tabela)]..'"/><Z><S><S X="401" L="798" Y="408" c="3" H="18" P="0,0,0.3,0.2,0,0,0,0" T="0" /></S><D /><O /></Z></C>')      
  117. end
  118. ---------------------------------
  119. -- @ Evento do teclado
  120. ---------------------------------
  121. function keyEvent(p)
  122.     if k == 32 and tfm.get.room.playerList[p].isFacingRight == true and info[p].time < os.time()-1500 then
  123.         info[p].time = os.time()
  124.         tfm.exec.movePlayer(p,0,0,true,100,0,false)
  125.     elseif k == 32 and tfm.get.room.playerList[p].isFacingRight == false and info[p].time < os.time()-1500 then
  126.         info[p].time = os.time()
  127.         tfm.exec.movePlayer(p,0,0,true,-100,0,false)
  128.     end
  129.  
  130.     local facingLeft = {}
  131.  
  132.     for name in pairs(tfm.get.room.playerList) do
  133.         for _,key in pairs{0,2,3,32} do
  134.         system.bindKeyboard(name, key, true)
  135.     end
  136.   end
  137. end
  138. function eventKeyboard(name, key, down, x, y)
  139.     if key == 32 then
  140.         for n,objectList in pairs(tfm.get.room.objectList) do
  141.             if name ~= n  and x >= objectList.x - 23 and x <= objectList.x + 23 and y >= objectList.y - 21 and y <= objectList.y + 21 then
  142.                 newData[name].Apple = newData[name].Apple + 1
  143.                 tfm.exec.removeObject(39)
  144.                 tfm.exec.removeObject(39)
  145.                 tfm.exec.setPlayerScore(name,newData[name].Apple)
  146.                 ui.addTextArea(0, "<font size='25'><B><VP>"..newData[name].Apple.."</font>", name,  40, 363, 97, 30, 0x324650, 0x000000, 0, true)
  147.                 tfm.exec.displayParticle(5,x,y,-0.2,-0.2,0,0)
  148.                 break
  149.             end
  150.         end
  151.     end
  152. end -- End do KeyEvent
  153. ---------------------------------
  154. -- @Função jogador sai da sala.
  155. ---------------------------------
  156. function eventPlayerLeft(name)
  157.     p=p-1
  158.     if p < 2 then
  159.         startGame = false
  160.         StartTime = false
  161.   end
  162. end    
  163. -----------------------------
  164. --@ Outras coisas
  165. -----------------------------  
  166. function lobby()
  167.     tfm.exec.newGame('<C><P L="1600" /><Z><S><S P="0,0,0.3,0.2,0,0,0,0" L="1545" o="ff8900" X="801" c="4" Y="68" T="12" H="85" /><S H="85" L="1545" o="df7800" X="800" c="4" Y="153" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S H="85" L="1545" o="9b5300" X="802" c="4" Y="322" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="1545" o="c26801" X="799" c="4" Y="237" T="12" H="85" /><S P="0,0,0,0.2,0,0,0,0" L="30" o="ffd700" X="16" Y="198" T="12" H="402" /><S L="30" o="ffcb00" X="1585" H="402" Y="200" T="12" P="0,0,0,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="1600" o="ffcb00" X="800" Y="383" T="12" H="40" /><S L="1600" o="ffcb00" X="799" H="30" Y="12" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="21" o="ffcb00" X="802" Y="196" T="12" H="339" /></S><D /><O /></Z></C>')
  168.     tfm.exec.setGameTime(9999999999)
  169.     startGame = false
  170.     StartTime = false
  171. end
  172. table.foreach(tfm.get.room.playerList, eventNewPlayer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement