Advertisement
Rawoas13

[Script] The Racing

Jan 18th, 2020
770
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.91 KB | None | 0 0
  1. --Creator: Hass
  2. --Made in: 15/01/2020
  3. --Last update: 18/01/2020
  4. --[[ Notes:
  5.     Does:
  6.        Create a random map where the floors disappear quickly. Be the fastest!
  7.     Keys:
  8.         Space --> Speed
  9. ]]--
  10.  
  11. tfm.exec.disableAutoNewGame()
  12. tfm.exec.disableAutoShaman()
  13. tfm.exec.disableAutoScore()
  14. for n in next,tfm.get.room.playerList do
  15.     tfm.exec.setPlayerScore(n,0)
  16. end
  17.  
  18. local generateMap=function()
  19.     local xml = '<C><P L="25000" H="99999" /><Z><S>%s</S><D><DS Y="50" X="40" /></D><O /><L><JD P1="15000,-10000"P2="15001,10000"c="EBFB81,100"/><JD P1="25000,-10000"P2="25001,10000"c="D98AAD,100"/></L></Z></C>'
  20.     for i = 1,1600 do
  21.         xml = xml:format('<S L="40" H="40" X="'..(60*i-30 + math.random(-10,10))..'" Y="'..(100+(math.random(-i/3,i/3)))..'" v="'..(3000 + i*100)..'" c="1" T="'..math.random(0,12)..'" o="'..math.random(0x000000,0xFFFFFF)..'" P=",,,.1,'..math.random(0,360)..',,," />'..(i<1600 and '%s' or ''))
  22.     end
  23.     tfm.exec.newGame(xml)
  24. end
  25.  
  26. velocity = 50
  27. key = 32
  28.  
  29. mice={}
  30. eventNewPlayer=function(n) mice[n]={right=true}
  31.     for _,k in next,{0,2,key} do
  32.         system.bindKeyboard(n,k,true,true)
  33.     end
  34. end
  35. table.foreach(tfm.get.room.playerList,eventNewPlayer)
  36.  
  37. eventNewGame=function() table.foreach(tfm.get.room.playerList,function(n) mice[n]={right=true} end) end
  38.  
  39. eventKeyboard=function(n,k)
  40.     if k==key then
  41.         tfm.exec.movePlayer(n,0,0,false,(mice[n].right and velocity or -velocity),0,true)
  42.     end
  43.     if k==0 then mice[n].right=false elseif k==2 then mice[n].right=true end
  44. end
  45.  
  46. eventLoop=function(t)
  47.     for n,v in next,tfm.get.room.playerList do
  48.         if v.x >= 15000 then
  49.             tfm.exec.giveCheese(n)
  50.         end
  51.         if v.x >= 25000 and tfm.get.room.current ~= "123" then
  52.             tfm.exec.playerVictory(n)
  53.             tfm.exec.setPlayerScore(n,100,true)
  54.             tfm.exec.newGame(123)
  55.         end
  56.     end
  57. end
  58.  
  59. generateMap()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement