bigtwisty

Digger

Apr 14th, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. --name Digger
  2. --version 1.0a
  3. local version = "1.0a"
  4.  
  5. local args = {...}
  6. local limX, limY
  7.  
  8. local function forward()
  9. while not turtle.forward() do
  10. turtle.dig()
  11. end
  12. end
  13.  
  14. local function screen(txt)
  15. term.clear()
  16. term.setCursorPos(1,1)
  17. print("Digger (v%s)",version)
  18. print("------------------")
  19. print(txt)
  20. end
  21.  
  22. local function turn(x,z)
  23. if x == limX then
  24. if z%2 == 0 then
  25. turtle.turnLeft()
  26. else
  27. turtle.turnRight()
  28. end
  29. elseif (x == 1) and (z ~= 1) then
  30. if z%2 == 1 then
  31. turtle.turnLeft()
  32. else
  33. turtle.turnRight()
  34. end
  35. end
  36. end
  37.  
  38. if #args ~= 2 then
  39. print("Usage: Digger [x] [z]")
  40. else
  41. limX = tonumber(args[1])
  42. limZ = tonumber(args[2])
  43. for z=1,limZ do
  44. for x=1,limX do
  45. screen(string.format("X:%d Z:%d",x,z))
  46. turtle.digUp()
  47. turtle.digDown()
  48. turn(x,z)
  49. if(x<limX) or (z<limZ) then
  50. forward()
  51. end
  52. end
  53. end
  54. end
Advertisement
Add Comment
Please, Sign In to add comment