Advertisement
Lion4ever

Jump Parkour

May 31st, 2015
681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.47 KB | None | 0 0
  1. local blocksInFront = 4
  2. local blocksBehind = 10
  3. local tpBackUp = true
  4. local checkBlockBelow = true
  5.  
  6. local jumps = {}
  7.  
  8. for i=0,1 do
  9.   for j=-5,5 do
  10.     for k=-5,5 do
  11.       local jump = vector.new(j,i,k)
  12.       local jumpL = jump:length()
  13.       if jumpL <= 5 and jumpL > 1.5 then
  14.         table.insert(jumps,jump)
  15.       end
  16.     end
  17.   end
  18. end
  19.  
  20. local function crossingPath(b,p)
  21.   for i=2,#p do
  22.     if (b-p[i]):length() <= 5.1 then
  23.       return true
  24.     end
  25.   end
  26.   return false
  27. end
  28.  
  29. local blocks = {}
  30. local catcher = vector.new(0,-30,0)
  31. local detecter = vector.new(0,2,0)
  32.  
  33. local catcherRad = ",27]"
  34.  
  35. local startP = vector.new(commands.getBlockPosition()) - catcher / 2
  36.  
  37. local tpCircle
  38.  
  39. local paraFuncs = {
  40. function()
  41.   repeat
  42.     local newB
  43.     while #blocks <= blocksInFront or not newB do
  44.       repeat
  45.         newB = (blocks[1] or startP) + jumps[math.random(#jumps)]
  46.       until not crossingPath(newB,blocks)
  47.       table.insert(blocks,1,newB)
  48.       commands.setblock(newB.x,newB.y,newB.z,
  49.           "minecraft:wool",math.random(0,15))
  50.     end
  51.     local tplayer = "@p["..tostring(blocks[blocksInFront] + detecter) .. ",1]"
  52.     tpCircle = "@p[" ..tostring(blocks[blocksInFront] + catcher) ..catcherRad
  53.     repeat
  54.     until commands.testfor(tplayer)
  55.     if #blocks > blocksInFront + blocksBehind + 2 then
  56.       local last = blocks[#blocks]
  57.       commands.setblock(last.x,last.y,last.z,"minecraft:air")
  58.       table.remove(blocks)
  59.     end
  60.     if blocks[1].y >= 250 then
  61.       blocksInFront = blocksInFront - 1
  62.     end
  63.   until blocksInFront <= 0
  64.   print("Reached the top of the map")
  65. end,
  66.  
  67. function()
  68.   print("Press any char to exit")
  69.   os.pullEvent("char")
  70.   print("Programm manuell program exit")
  71. end}
  72.  
  73. if tpBackUp then
  74.   paraFuncs[3]=function()
  75.     while true do
  76.       if commands.testfor(tpCircle) then
  77.         local checkP = blocks[blocksInFront+1]
  78.         commands.tp(tpCircle,checkP.x,checkP.y+2,checkP.z)
  79.       end
  80.     end
  81.   end
  82. end
  83.  
  84. if checkBlockBelow then
  85.   table.insert(paraFuncs,function()
  86.     local cur
  87.     repeat
  88.       sleep(1)
  89.       cur = blocks[blocksInFront+1] or vector.new(commands.getBlockPosition())
  90.     until commands.testforblock(cur.x,cur.y,cur.z,"minecraft:air")
  91.     print("Block below was broken")
  92.   end)
  93. end
  94.  
  95. parallel.waitForAny(unpack(paraFuncs))
  96.  
  97. commands.tp("@a["..tostring(blocks[1])..catcherRad,commands.getBlockPosition())
  98. for i,j in ipairs(blocks) do
  99.   commands.setblock(j.x,j.y,j.z,"minecraft:air")
  100. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement