HaniiPuppy

AutomateMakingTinkersRoads

Sep 10th, 2013
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.19 KB | None | 0 0
  1. --[[
  2. The turtle should be placed in front of the basin that the gravel goes into facing it, with a faucet above the basin. The turtle should have a block that can carry redstone signals (I like using a redstone lamp) directly above it - this will trigger the faucet. A fuel source (such as coal, coal coke, etc.) should be in inventory slot 16. Gravel should be in inventory slot 15. As long as there is gravel in inventory slot 15, gravel in any of the other inventory slots can be used, and the gravel in inventory slot 15 will be used last.
  3.  
  4. The program takes one argument, which is the number of blocks of gravel to turn into brownstone.
  5. --]]
  6.  
  7. function Main(Amount)
  8.     MainCounter = 0
  9.  
  10.     while MainCounter < Amount do
  11.         CheckFuel(16, 2)
  12.  
  13.         if ReplaceGravel(15) then
  14.             FlickFaucet()
  15.             WaitForGravelToCool()
  16.         end
  17.  
  18.         MainCounter = MainCounter + 1
  19.     end
  20. end
  21.  
  22. function CheckFuel(FuelInventorySlot, AmountNeeded)
  23.     print("Checking Fuel")
  24.     if turtle.getFuelLevel() < 2 then
  25.         turtle.select(FuelInventorySlot)
  26.         turtle.refuel(2)
  27.     end
  28.     print("Finished Checking Fuel")
  29. end
  30.  
  31. function ReplaceGravel(GravelSlot)
  32.     print("Replacing Gravel")
  33.     SelectSlot = 1
  34.     Finished = false
  35.  
  36.     print("Removing Gravel")
  37.     turtle.suck()
  38.     print("Gravel Removed")
  39.  
  40.     print("Looking For Gravel")
  41.     while SelectSlot <= 15 and not Finished do
  42.         turtle.select(SelectSlot)
  43.         if turtle.compareTo(15) then
  44.             turtle.drop(1)
  45.             Finished = true
  46.             print("Gravel Replaced Successfully")
  47.             return true
  48.         end
  49.  
  50.         SelectSlot = SelectSlot + 1
  51.     end
  52.  
  53.     print("Could Not Replace Gravel")
  54.     return false
  55. end
  56.  
  57. function FlickFaucet()
  58.     print("Flicking Faucet")
  59.     os.sleep(0.2)
  60.     redstone.setOutput("top", true)
  61.     os.sleep(0.5)
  62.     redstone.setOutput("top", false)
  63.     print("Faucet Flicked")
  64. end
  65.  
  66. function WaitForGravelToCool()
  67.     print("Waiting For Gravel To Cool")
  68.     os.sleep(5.5)
  69.     print("Finished Waiting")
  70. end
  71.  
  72. args = {...}
  73.  
  74. if #args > 0 then
  75.     Main(tonumber(args[1]))
  76. else
  77.     print("Requires number of blocks to be produced.")
  78. end
Advertisement
Add Comment
Please, Sign In to add comment