SHARE
TWEET

Old parkour script

TheIncgi Aug 21st, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ----------------------------------------------------------------------------------------------------------------
  2. --  Sets the block that the player is jumping from (separate script)
  3. ----------------------------------------------------------------------------------------------------------------
  4. bx,by,bz = lookingAt()
  5. by=by
  6. hud3D.clearAll()
  7. quickHB(bx,by+1,bz)
  8.  
  9.  
  10. ----------------------------------------------------------------------------------------------------------------
  11. -- Parkour script below:
  12. ----------------------------------------------------------------------------------------------------------------
  13.  
  14. function lookingAt()
  15.   local player = getPlayer()
  16.   yaw = player.yaw
  17.   return table.unpack(player.lookingAt)
  18. end
  19. function centerViewOnBlock()
  20.   local lx,ly,lz = lookingAt()
  21.   lookAt(lx+.5,ly+.5,lz+.5, 1000)
  22.   sleep(1000)
  23. end
  24. function isOnBlock()
  25.   return getPlayer().onGround
  26. end
  27. function dist(a, b)
  28.   local dx = b[1]-a[1]
  29.   local dy = b[2]-a[2]
  30.   local dz = b[3]-a[3]
  31.   return math.sqrt( dx*dx + dy*dy + dz*dz)
  32. end
  33. function getDxDz()
  34.  local x, z = tx,tz
  35.  local px,_,pz = bx,by,bz --getPlayerBlockPos()
  36.  local dx = x-px
  37.   --local dy = y-py
  38.  local dz = z-pz
  39.  return dx,dz
  40. end
  41. function math.sign(x)
  42.   if(x>0)then return 1 end
  43.   if(x<0)then return -1 end
  44.   return 0
  45. end
  46. function isInBlockBounds(x,y,z, all)
  47.   all = all or false
  48.   local buffer = .1 --was .2
  49.   local px,py,pz = getPlayerPos()
  50.   local pbx, pby ,pbz = getPlayerBlockPos()
  51.  
  52.   local dx,dz = getDxDz(x,z)
  53.   dx = math.sign(dx)
  54.   dz = math.sign(dz)
  55.   --log(dx,dz)
  56.   if(dx==1 or all)then --pos X direction
  57.    -- log("")
  58.     if(px > x+1+buffer)then
  59.     --log("Over pos X")
  60.     return false end
  61.   end
  62.   if(dx==-1 or all)then -- neg x
  63.     --log("c2")
  64.     if(px < x-buffer)then
  65.     --log("Over neg X")
  66.     return false end
  67.   end
  68.   if(dz==1 or all)then
  69.     if(pz > z+1+buffer)then --log("Over Neg Z")
  70.     return false end
  71.   end
  72.   if(dz==-1 or all)then
  73.     if(pz < z-buffer)then --log("Over Pos Z")
  74.     return false end
  75.   end
  76.   return true
  77. end
  78. function isSneaking()
  79.   return getPlayer().isSneaking
  80. end
  81. function hasFallen(by)
  82.   local px,py,pz = getPlayerPos()
  83.   if(py<ty+.25 and py<by+.25)then return true end
  84.   return false
  85. end
  86. function randomColor()
  87.   local r = math.random(7)
  88. --  "&0&1&2&3&4&5&6&7&8&9&a&b&c&d&e&f"
  89.   return ("d5e9632"):sub(r,r)
  90. end
  91. function doJump()
  92.   --local bx,by,bz = getPlayerBlockPos()
  93.   by = by-1
  94.   if(isSneaking())then
  95.     sneak(10)
  96.     sleep(1000)
  97.     log("&ePlayer was sneaking")
  98.   end
  99.   forward(-1)
  100.   waitTick()
  101.   sprint(true)
  102.  
  103.   while(isOnBlock() and isInBlockBounds(bx, by, bz))do
  104.     --do nothing
  105.     waitTick()
  106.   end
  107.   if(isOnBlock())then
  108.     jump()
  109.     while(not isInBlockBounds(tx,ty,tz, true) and not hasFallen(by))do
  110.       --do nothing
  111.     end
  112.     forward(0)
  113.     sneak(-1)
  114.     back(600)
  115.     sleep(800)
  116.     log("&4&O@@&f&"..randomColor().."Jump done&4&O@@")
  117.   else
  118.     forward(0)
  119.     log("&eWaited too long to jump")
  120.     log(getPlayerPos())
  121.     log(tx,ty,tz)
  122.   end
  123. end
  124. function checkDist()
  125.   local d = dist({tx,ty,tz}, {getPlayerBlockPos()})
  126.   if(d>=6)then
  127.     log("&cWarning distance is 6+ &f(&e"..d.."&f)")--, "choice","continue","abort")
  128.     sleep(10000)
  129.     return true --ans == "continue"
  130.   else
  131.     log("&aDistance to jump &f(&e"..d.."&f)")
  132.   end
  133.   return true
  134. end
  135. function quickHB(x,y,z)
  136.   hb = hud3D.newBlock()
  137.   hb.setPos(x,y,z)
  138.   hb.enableDraw()
  139.   hb.xray(true)
  140. end
  141.  
  142. if(parkour)then return end
  143. parkour = true
  144.  
  145. tx,ty,tz = lookingAt()
  146.  
  147. if(not (bx and by and bz))then
  148.   bx,by,bz = getPlayerBlockPos()
  149.   by=by-1
  150. end
  151.  
  152.  
  153.  
  154. --if(not isInBlockBounds(bx,by,bz))then
  155. --  log("&cNot in block bounds")
  156. --  parkour = false
  157.  -- return
  158. --end
  159.  
  160. if(checkDist())then
  161.   hud3D.clearAll()
  162.   quickHB(tx,ty,tz)
  163.   quickHB(bx,by+1,bz)
  164.   doJump()
  165. end
  166. bx,by,bz = tx,ty,tz
  167. parkour = false
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top