Advertisement
Guest User

makeroom.lua

a guest
Jan 4th, 2025
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.04 KB | None | 0 0
  1. width = tonumber(arg[1])
  2. length = tonumber(arg[2])
  3. current_x = 0
  4. current_y = 0
  5.  
  6. function move_back_to ( y )
  7. turtle.turnLeft()
  8. turtle.turnLeft()
  9. while current_y > y do
  10. turtle.dig()
  11. turtle.forward()
  12. current_y = current_y - 1
  13. end
  14. turtle.turnLeft()
  15. turtle.turnLeft()
  16. end
  17.  
  18. function move_forward_to ( y )
  19. while current_y < y do
  20. turtle.dig()
  21. turtle.forward()
  22. current_y = current_y + 1
  23. end
  24. end
  25.  
  26. function move_left_to ( x )
  27. turtle.turnLeft()
  28. while current_x > x do
  29. turtle.dig()
  30. turtle.forward()
  31. current_x = current_x - 1
  32. end
  33. turtle.turnRight()
  34. end
  35.  
  36. function move_right_to ( x )
  37. turtle.turnRight()
  38. while current_x < x do
  39. turtle.dig()
  40. turtle.forward()
  41. current_x = current_x + 1
  42. end
  43. turtle.turnLeft()
  44. end
  45.  
  46. function move_to ( x , y )
  47.  
  48. if x > current_x then
  49. move_right_to(x)
  50. end
  51.  
  52. if x < current_x then
  53. move_left_to(x)
  54. end
  55.  
  56. if y > current_y then
  57. move_forward_to(y)
  58. end
  59.  
  60. if y < current_y then
  61. move_back_to(y)
  62. end
  63.  
  64. end
  65.  
  66. for x=0,width do
  67. for y=0,length do
  68. move_to(x,y)
  69. turtle.digUp()
  70. end
  71. end
  72.  
  73. move_to(0,0)
  74.  
  75.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement