logg

Untitled

Mar 6th, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. --betterExcavate, now with support for non-square finite holes! And it won't dump its fuel on the ground!
  2.  
  3. --Get input
  4. lwh={...}
  5. if lwh[2]==nil then --allow optional second parameter
  6. lwh[2]=lwh[1]
  7. end
  8. if lwh[3]==nil then --allow optional third parameter
  9. lwh[3]=2^15
  10. end
  11. for i=1,3 do
  12. lwh[i]=tonumber(lwh[i])
  13. end
  14. --
  15. local function forward()
  16. if turtle.getFuelLevel() == 0 then
  17. if not turtle.refuel() then
  18. print("I need fuel!")
  19. while not turtle.refuel() do
  20. sleep(0.5)
  21. end
  22. end
  23. end
  24. turtle.dig()
  25. turtle.forward()
  26. end
  27. --Dig
  28. for h=1,lwh[3] do --height
  29. for w=1,lwh[2] do --width
  30. for l=2,lwh[1] do --length
  31. forward()
  32. end
  33. if w==lwh[2] then
  34. print("Done with this layer!")
  35. else
  36. if w%2==1 then
  37. turtle.turnRight()
  38. forward()
  39. turtle.turnRight()
  40. else
  41. turtle.turnLeft()
  42. forward()
  43. turtle.turnLeft()
  44. end
  45. end
  46. end
  47. for i=0,lwh[2]%2 do
  48. turtle.turnRight()
  49. end
  50. if h~=lwh[3] then
  51. turtle.digDown()
  52. turtle.down()
  53. end
  54. if lwh[2]%2==0 then
  55. l,w,lwh[1],lwh[2]=w,l,lwh[2],lwh[1]
  56. end
  57. end
Advertisement
Add Comment
Please, Sign In to add comment