Advertisement
Ulthean

digTunnels

Jan 15th, 2013
11,898
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.30 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. -- ------------------------------------------------------------ --
  10. -- START OF THE CODE THAT GETS EXECUTED WHEN THE PROGRAM STARTS --
  11. -- ------------------------------------------------------------ --
  12.  
  13. -- LOAD FUNCTIONS FROM THE OTHER FILES
  14. os.loadAPI("api_digTunnels")
  15. os.loadAPI("api_sharedFunctions")
  16. os.loadAPI("api_turtleExt")
  17.  
  18. -- GET THE CONFIGURATION OF THE PROGRAM
  19. local args={...}
  20. local configuration = api_sharedFunctions.getConfig("config", args)
  21. if configuration == nil then
  22.   return
  23. end
  24.  
  25. -- USED TO KEEP TRACK OF THE CURRENT POSITION
  26. configuration.currentL = 1
  27. configuration.currentT = 1
  28. configuration.currentS = 0
  29.  
  30. -- CHECK THE MINIMAL FUEL VALUE SPECIFIED BY THE USER
  31. if (configuration.departureFuel < 400) then
  32.   print("Warning: Low fuel value chosen")
  33.   print("Do you wish to proceed? (Y/N)")
  34.   local answer=io.read()
  35.   if not (answer=="Y") then
  36.     return
  37.   end
  38. end
  39.  
  40. -- RESTOCK THE TURTLE
  41. api_sharedFunctions.dropoffAndRestock(configuration, 0, false, true, true)
  42.  
  43. -- FOR EVERY LEVEL
  44. for curL = 1 + configuration.skipL, configuration.numL do
  45.   local firstT = 1
  46.   if curL == 1 + configuration.skipL then
  47.     firstT = firstT + configuration.skipT
  48.   end
  49.   -- FOR EVERY TUNNEL
  50.   for curT = firstT, configuration.numT do
  51.     local firstS = 0
  52.     if (curL == 1 + configuration.skipL) and (curT == 1 + configuration.skipT) and (configuration.skipS~=0) then
  53.       firstS = 1 + configuration.skipS
  54.     end
  55.     -- FOR EVERY SHAFT
  56.     for curS = firstS, configuration.numS do
  57.       api_sharedFunctions.moveToLocation(configuration, curL, curT, curS)
  58.       api_digTunnels.digSegment(configuration)
  59.       if api_sharedFunctions.needsRestocking(configuration) then
  60.         api_sharedFunctions.dropoffAndRestock(configuration, 0, false, false, false)
  61.       end
  62.     end
  63.   end
  64. end
  65.  
  66. -- RETURN TO START AND DROPOFF
  67. api_sharedFunctions.moveToLocation(configuration, 1, 1, 0)
  68. api_sharedFunctions.dropoff(configuration, 0, true, true)
  69.  
  70. -- ---------------------------------------------------------- --
  71. -- END OF THE CODE THAT GETS EXECUTED WHEN THE PROGRAM STARTS --
  72. -- ---------------------------------------------------------- --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement