Advertisement
OfficialStamper

digdig.lua

Jan 30th, 2023 (edited)
742
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.33 KB | Gaming | 0 0
  1. --
  2.  
  3. --how far foreward
  4. local howFar = 128
  5. local triesBeforeFailue = 16
  6.  
  7. --reverse to begining or wait at end
  8. --local rtn = true --get back over that lava
  9.  
  10. local t = turtle --lazy typing
  11. local pos = 0
  12. local try = 0
  13. --local returnNow = false
  14.  
  15. t.select(16) -- slot with torches, or mine will start here, good for nether
  16.  
  17. for i = 1, howFar do
  18.     pos = i
  19.     try = 0
  20.     f = t.detect()
  21.     u = t.detectUp()
  22.     d = t.detectDown()
  23.     while f or u or d do
  24.         if f then t.dig(); end
  25.         if u then t.digUp(); end
  26.         if d then t.digDown(); end
  27.         try = try + 1
  28.         if try > triesBeforeFailue then
  29.             print("Attempted "..try.." tries.  Attempting continue from pos:"..pos)
  30.             break
  31.         end
  32.         sleep(0.05)
  33.         f = t.detect()
  34.         u = t.detectUp()
  35.         d = t.detectDown()
  36.         if not d and math.fmod(i, 8) == 0 then
  37.             if not t.placeDown() then
  38.                 print("I'm scared of the dark:"..pos)
  39.                 break
  40.             end
  41.         end
  42.     end
  43.     if not t.forward() then
  44.         print("this baby ain't going nowhere!")
  45.         break
  46.     end
  47.     try = 0
  48.     sleep(0.05)
  49. end
  50.  
  51. print("Got to: "..pos)
  52.  
  53. t.turnRight()
  54. t.turnRight()
  55.  
  56. for i = pos, 1, -1 do
  57.     while not t.forward() do
  58.         t.dig()
  59.     end
  60.     sleep(0.05)
  61. end
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement