Advertisement
Bolodefchoco_LUAXML

[Game] Doors

Oct 15th, 2016
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.75 KB | None | 0 0
  1. --Creator: Bolodefchoco
  2. --Made in: 16/10/2016
  3. --Last update: 16/10/2016
  4. --[[ Notes:
  5.     Does:
  6.         Um jogo semelhante ao evento de halloween (sistema de portas)
  7. ]]--
  8.  
  9. tfm.exec.disableAutoShaman()
  10. tfm.exec.disableAutoNewGame()
  11. tfm.exec.disableAfkDeath()
  12. toDespawn = {}
  13.  
  14. mice = {}
  15. eventNewPlayer = function(n)
  16.     if not mice[n] then
  17.         mice[n] = {deaths=0,candies=0}
  18.     end
  19. end
  20. table.foreach(tfm.get.room.playerList,eventNewPlayer)
  21. eventPlayerDied = function(n)
  22.     mice[n].deaths = mice[n].deaths + 1
  23.     tfm.exec.respawnPlayer(n)
  24. end
  25.  
  26. system.spawnDoor = function()
  27.     ui.addTextArea(0,"",nil,50,120,100,220,-1,0xA536D3,1,true)
  28.     ui.addTextArea(1,"",nil,250,120,100,220,-1,0xA536D3,1,true)
  29.     ui.addTextArea(2,"",nil,450,120,100,220,-1,0xA536D3,1,true)
  30.     ui.addTextArea(3,"",nil,650,122,100,220,-1,0xA536D3,1,true)
  31. end
  32.  
  33. system.door = function(id,c,a)
  34.     ui.addTextArea(id,"",nil,250 + (id-1)*200,120,100,220,c,0xA536D3,a,true)
  35. end
  36.  
  37. system.spawnTimer = function()
  38.     ui.addTextArea(4,"",nil,75,55,50,50,0x550479,0xA536D3,1,true)
  39.     ui.addTextArea(5,"",nil,275,55,50,50,0x550479,0xA536D3,1,true)
  40.     ui.addTextArea(6,"",nil,475,55,50,50,0x550479,0xA536D3,1,true)
  41.     ui.addTextArea(7,"",nil,675,55,50,50,0x550479,0xA536D3,1,true)
  42. end
  43.  
  44. timer,on,timers = 10,false,{10,0,0,-1}
  45. eventNewGame = function()
  46.     ui.addTextArea(1000,"",nil,-1500,-1500,3000,3000,1,1,.4,true)
  47.     tfm.exec.setGameTime(1e7)
  48.     system.spawnDoor()
  49.     system.spawnTimer()
  50. end
  51.  
  52. eventLoop = function()
  53.     for k,v in next,tfm.get.room.playerList do
  54.         ui.addTextArea(100,"<B><R>"..mice[k].deaths.."\n<PT>"..mice[k].candies,k,5,30,nil,nil,1,1,0,true)
  55.     end
  56.     for k,v in ipairs(toDespawn) do
  57.         if v[1] <= os.time()-5000 then
  58.             tfm.exec.removeObject(v[2])
  59.             table.remove(toDespawn,k)
  60.         end
  61.     end
  62.     timer = timer + .5
  63.     if timer%15 == 0 then
  64.         on = not on
  65.         system.door(timers[4],-1)
  66.         timers[2] = math.random(4,7)
  67.         repeat
  68.             timers[3] = math.random(4,7)
  69.         until timers[2] ~= timers[3]
  70.     end
  71.     if on then
  72.         timers[1] = timers[1] - .5
  73.         local format = "<font size='6'>\n<p align='center'><font size='20'><B><V>"..math.ceil(timers[1])
  74.         ui.updateTextArea(timers[2],format,nil)
  75.         ui.updateTextArea(timers[3],format,nil)
  76.         if timers[1] == 0 then
  77.             on = false
  78.             ui.updateTextArea(timers[2],"",nil)
  79.             ui.updateTextArea(timers[3],"",nil)
  80.             timers[4] = timers[math.random(2,3)] - 4
  81.             timers[1] = 10
  82.             timers[2] = 0
  83.             timers[3] = 0
  84.             local rand = trick[math.random(#trick)];rand()
  85.         end
  86.     else
  87.         local id = timers[4]
  88.         system.door(id,0x380438,.5)
  89.     end
  90. end
  91.  
  92. tfm.exec.newGame(6104453)
  93.  
  94. trick = {}
  95.  
  96. trick[1] --[[ Ice ]] = function()
  97.     local x1 = 245 + (timers[4]-1)*200
  98.     local x2 = x1 + 110
  99.     for k,v in next,tfm.get.room.playerList do
  100.         if v.x >= x1 and v.x <= x2 then
  101.             tfm.exec.killPlayer(k)
  102.             toDespawn[#toDespawn+1] = {os.time(),tfm.exec.addShamanObject(54,v.x,v.y)}
  103.         end
  104.     end
  105.     for i = 1,20 do
  106.         tfm.exec.displayParticle(0,math.random(x1,x2) + math.random(-i,i),210,math.random(-2,2),math.random(0,3),math.random(-.1,.1))
  107.     end
  108. end
  109.  
  110. trick[2] --[[ Cannon ]] = function()
  111.     local x1 = 245 + (timers[4]-1)*200
  112.     local angle = (timers[4] < 3 and 90 or 270)
  113.     for i = 1,2 do
  114.         tfm.exec.addShamanObject(17,x1,400 - (i * 40),angle)
  115.     end
  116. end
  117.  
  118. trick[3] --[[ Balloons ]] = function()
  119.     local x1 = 245 + (timers[4]-1)*200
  120.     for i = 1,10 do
  121.         toDespawn[#toDespawn+1] = {os.time() + math.random(3000),tfm.exec.addShamanObject(28,x1 + 20 + i*math.random(10),360 - i*math.random(10),0,0,10)}
  122.     end
  123. end
  124.  
  125. trick[4] --[[ Kill ]] = function()
  126.     local x1 = 245 + (timers[4]-1)*200
  127.     local x2 = x1 + 110
  128.     for k,v in next,tfm.get.room.playerList do
  129.         if v.x >= x1 and v.x <= x2 then
  130.             tfm.exec.killPlayer(k)
  131.         end
  132.     end
  133.     for i=1,50 do
  134.         local speed = {-.2,0}
  135.         tfm.exec.displayParticle(2,x1+50+math.sin(i)*80,360-math.cos(i)*10,.1,speed[math.random(#speed)])
  136.     end
  137. end
  138.  
  139. trick[5] --[[ Candie ]] = function()
  140.     local x1 = 245 + (timers[4]-1)*200
  141.     local x2 = x1 + 110
  142.     for k,v in next,tfm.get.room.playerList do
  143.         if v.x >= x1 and v.x <= x2 then
  144.             mice[k].candies = mice[k].candies + 1
  145.         end
  146.     end
  147.     for i = 1,15 do
  148.         local info = {x1 + 50 + math.random(-i,i),250 + math.random(i*2),math.random(-1,1),math.random(-1,1)}
  149.         tfm.exec.displayParticle(9,table.unpack(info))
  150.         tfm.exec.displayParticle(11,table.unpack(info))
  151.     end
  152. end
  153.  
  154. trick[6] --[[ Vampire ]] = function()
  155.     local x1 = 245 + (timers[4]-1)*200
  156.     local x2 = x1 + 110
  157.     for k,v in next,tfm.get.room.playerList do
  158.         if v.x >= x1 and v.x <= x2 then
  159.             tfm.exec.setVampirePlayer(k)
  160.         end
  161.     end
  162.     for i = 1,15 do
  163.         local info = {x1 + 50 + math.random(-i,i),250 + math.random(i*2),math.random(-1,1),math.random(-1,1)}
  164.         tfm.exec.displayParticle(0,table.unpack(info)) 
  165.         tfm.exec.displayParticle(13,table.unpack(info))
  166.         tfm.exec.displayParticle(0,table.unpack(info)) 
  167.     end
  168. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement