Advertisement
Ulthean

api_digShafts

Jan 12th, 2013
11,774
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.23 KB | None | 0 0
  1. -- VALUES FOR THE DIRECTIONS
  2. local up = "up"
  3. local down = "down"
  4. local forward = "forward"
  5. local back  = "back"
  6. local right = "right"
  7. local left = "left"
  8.  
  9. -- LOAD FUNCTIONS FROM THE OTHER FILES
  10. os.loadAPI("api_sharedFunctions")
  11. os.loadAPI("api_turtleExt")
  12.  
  13. -- -------------------------------------------- --
  14. -- START OF THE FUNCTIONS SPECIFIC TO digShafts --
  15. -- -------------------------------------------- --
  16.  
  17. -- DIGS A SINGLE SHAFT, THE PARAMETERS WILL DETERMINE THE LENGTH OF THE SHAFT
  18. function digShaft(configuration, dir)
  19.   local squaresMoved=0
  20.   for i=1,configuration.centerRadius+api_sharedFunctions.calculateMoves(configuration, configuration.currentL, 0, configuration.currentS) do
  21.     if configuration.placeTorches and (i % 6==5) then
  22.       api_turtleExt.place(down, 1)
  23.     end
  24.     if api_turtleExt.digAndMove(forward)==0 then
  25.       api_sharedFunctions.reportObstruction(configuration, dir)
  26.       break
  27.     end
  28.     squaresMoved = squaresMoved + 1
  29.     api_turtleExt.dig(down)
  30.   end
  31.   api_turtleExt.turnTo(back)
  32.   api_turtleExt.digAndMove(forward, squaresMoved, 0)
  33. end
  34.  
  35. -- ------------------------------------------ --
  36. -- END OF THE FUNCTIONS SPECIFIC TO digShafts --
  37. -- ------------------------------------------ --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement