Jahn_M_L

room2

Feb 10th, 2022 (edited)
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. local args = {...}
  2. local xCurrent, zCurrent = 1, 1
  3. local xMax, zMax
  4. local facing = 0 --start 0, gedreht 1
  5. if #args == 2 then
  6. xMax = tonumber(args[1])
  7. zMax = tonumber(args[2])
  8. elseif #args==0 then
  9. xMax, zMax = 3, 3
  10. end
  11.  
  12. function digUpDown()
  13. while turtle.detectUp() do
  14. turtle.digUp()
  15. sleep(1)
  16. end
  17. while turtle.detectDown() do
  18. turtle.digDown()
  19. sleep(1)
  20. end
  21. end
  22.  
  23. function dig()
  24. digUpDown()
  25.  
  26. if turtle.detect() then
  27. while turtle.detect() do
  28. turtle.dig()
  29. sleep(1)
  30. end
  31. end
  32. end
  33.  
  34.  
  35.  
  36. function start()
  37. turtle.refuel()
  38. while zCurrent <= zMax do
  39. if facing == 0 then
  40. while xCurrent < xMax do
  41. dig()
  42. turtle.forward()
  43. xCurrent = xCurrent +1
  44. end
  45. if zCurrent < zMax then
  46. turtle.turnLeft()
  47. dig()
  48. turtle.forward()
  49. turtle.turnLeft()
  50. zCurrent = zCurrent +1
  51. facing = 1
  52. else
  53. digUpDown()
  54. end
  55. end
  56.  
  57. if facing == 1 then
  58. while xCurrent > 1 do
  59. dig()
  60. turtle.forward()
  61. xCurrent = xCurrent -1
  62. end
  63. if zCurrent < zMax then
  64. turtle.turnRight()
  65. dig()
  66. turtle.forward()
  67. turtle.turnRight()
  68. zCurrent = zCurrent +1
  69. facing = 0
  70. else
  71. digUpDown()
  72. end
  73. end
  74. end
  75. end
  76.  
  77.  
  78.  
  79.  
  80. --Begin
  81. if #args == 2 then
  82. start()
  83. elseif #args == 0 then
  84. start()
  85. else
  86. print("Usage: room <x> <z>")
  87. end
  88.  
Add Comment
Please, Sign In to add comment