Advertisement
Guest User

flat

a guest
Apr 3rd, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. arg = {...}
  2.  
  3. length = arg[1]
  4. width = arg[2]
  5. dir = arg[3]
  6. cSlot = 1
  7. slots = 16
  8. turtle.select(13)
  9. turtle.refuel()
  10. turtle.select(1)
  11.  
  12. if (length == nil or width == nil) then
  13. print ("Usage: flat <length> <width> <1=up else down>")
  14. return
  15. end
  16.  
  17. function empty()
  18. if (turtle.getItemCount(slots) == 0) then
  19. print(string.format("I am empty. Please load more materials in slot %d to continue.", slots))
  20. while (turtle.getItemCount(slots) == 0) do
  21. sleep(1)
  22. end
  23. end
  24. if (turtle.getItemCount(cSlot) == 0) then
  25. cSlot = cSlot + 1
  26. turtle.select(cSlot)
  27. end
  28. end
  29.  
  30. for i=0,(width - 1),1 do
  31.  
  32. for j=1,(length - 1),1 do
  33. empty()
  34. turtle.forward()
  35. if (dir==1) then turtle.placeUp()
  36. else
  37. turtle.placeDown()
  38. end
  39. end
  40.  
  41. if (i % 2 == 0) then
  42.  
  43. if (i ~= width - 1) then
  44. turtle.turnRight()
  45. turtle.forward()
  46. turtle.turnRight()
  47. empty()
  48.  
  49. turtle.placeDown()
  50. end
  51. else
  52. if (i ~= width - 1) then
  53. turtle.turnLeft()
  54. turtle.forward()
  55. turtle.turnLeft()
  56. empty()
  57. if (dir==1) then turtle.placeUp()
  58. else
  59. turtle.placeDown()
  60. end
  61. end
  62. end
  63.  
  64.  
  65. if (j ~= length - 1) then
  66. empty()
  67. if(dir==1) then turtle.placeUp()
  68. else
  69. turtle.placeDown()
  70. end
  71. end
  72. end
  73.  
  74. print("\nSurface complete.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement