XLT_Frank

Ender Quarry v1

Apr 20th, 2014
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.76 KB | None | 0 0
  1. fuelChestLocation = 1
  2. fuelLocation = 2
  3. fenceChestLocation = 5
  4. fenceLocation = 6
  5. miningChestLocation = 9
  6. endQuarryLocation = 10
  7. trashLocation = 16
  8.  
  9. function layFence(size)
  10.   for i = 1,size do
  11.     if (turtle.getFuelLevel() <= 1) then -- check if fuel is low
  12.       getFuel() -- cal function load fuel
  13.     end
  14.     if (turtle.detectDown()) then -- Verify area below is clear
  15.       turtle.select(trashLocation) -- select position for trash
  16.       turtle.digDown() -- clear space for fence
  17.       turtle.drop() -- clear trash
  18.     end  
  19.     if (turtle.getItemCount(fenceLocation) <= 0) then -- check if fences are loaded
  20.       getFences() -- call function to load fences
  21.     end
  22.     turtle.select(fenceLocation) -- select position of fences
  23.     turtle.placeDown() -- place fence
  24.     turtle.select(trashLocation)
  25.     turtle.dig() -- clear space forward
  26.     turtle.drop() -- clear trash
  27.     turtle.forward() -- move forward
  28.   end
  29. end
  30.  
  31. function removeFence(size)
  32.   for i = 1,size do
  33.     if (turtle.getFuelLevel() <= 1) then -- check if fuel is low
  34.       getFuel() -- cal function load fuel
  35.     end
  36.  
  37.     if (turtle.getItemCount(fenceLocation) > 63) then
  38.       turtle.select(miningChestLocation)
  39.       turtle.placeUp() -- place ender chest
  40.       turtle.select(fenceLocation) -- select position where fences are being placed
  41.       turtle.dropUp(64) -- push stack of fences into above inventory
  42.       turtle.select(miningChestLocation) -- select position where fence chest is to be stored
  43.       turtle.digUp() -- grab fence chest
  44.     end
  45.  
  46.     turtle.select(fenceLocation) -- select position of fences
  47.     turtle.digDown() -- pickup fence
  48.     turtle.forward() -- move forward
  49.   end
  50. end
  51.  
  52. function getFuel()
  53.   if turtle.detectUp() then -- verify space above is clear
  54.     turtle.select(trashLocation) -- select position for trash
  55.     turtle.digUp() -- clear space for Ender chest
  56.     turtle.drop() -- clear trash
  57.   end  
  58.   turtle.select(fuelChestLocation) -- select position where Ender chest is located that contains fuel
  59.   turtle.placeUp() -- place ender chest
  60.   turtle.select(fuelLocation) -- select position where fuel is to be kept
  61.   turtle.suckUp() -- grab a stack of fuel
  62.   turtle.refuel(64) -- refuel
  63.   turtle.select(fuelChestLocation) -- return to position for storing ender chest
  64.   turtle.digUp() -- retrieve Ender chest
  65. end
  66.  
  67. function getFences()
  68.   if turtle.detectUp() then -- verify space above is clear
  69.     turtle.select(trashLocation) -- select position for trash
  70.     turtle.digUp() -- clear space for Ender chest
  71.     turtle.drop() -- clear trash
  72.   end  
  73.   turtle.select(fenceChestLocation) -- select position where Ender chest is located that contains fences
  74.   turtle.placeUp() -- place Ender chest
  75.   turtle.select(fenceLocation) -- select position where fences is to be kept
  76.   turtle.suckUp()  -- grab a stack of fences
  77.   turtle.select(fenceChestLocation) -- return to position for storing ender chest
  78.   turtle.digUp() -- retrieve Ender chest
  79. end
  80.  
  81.  
  82. print("What would you like to do? Make a selection:")
  83. print("  1 - Place Ender Quarry")
  84. print("  2 - Pickup Ender Quarry")
  85. write("Choice: ")
  86. local input = read()
  87. write("What size? ")
  88. local size = read()
  89.  
  90. if (input == "1") then
  91.   for i = 1,4 do
  92.     layFence(size)
  93.     turtle.turnLeft()
  94.   end
  95.   turtle.select(fenceLocation) -- select position where fences are being placed
  96.   turtle.digDown()
  97.   turtle.select(endQuarryLocation)
  98.   turtle.placeDown()
  99.   turtle.up()
  100.   turtle.select(miningChestLocation)
  101.   turtle.placeDown()
  102.   turtle.select(fenceLocation)
  103.   turtle.dropDown()
  104. elseif (input == "2") then
  105.   turtle.select(miningChestLocation)
  106.   turtle.digDown()
  107.   turtle.down()
  108.   turtle.select(endQuarryLocation)
  109.   turtle.digDown()
  110.   for i = 1,4 do
  111.     removeFence(size)
  112.     turtle.turnLeft()
  113.   end
  114. end
Advertisement
Add Comment
Please, Sign In to add comment