Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --******************************--
- --Self-Operating Cobbleston Farm--
- --******************************--
- --Variable Declarations
- local inventoryFull = false
- local chestFull = false
- local ready = 0
- local runningTotal = 0
- local makeFarm = true
- local normCobble = 0
- local compCobble = 0
- local firstDeposit = false
- --Function Declarations
- function decideToMake()
- print("-------------------------------------")
- print("------- Auto Cobblestone Farm -------")
- print("-------------------------------------")
- print("Are you resuming an operation (y/n)?")
- local userInput = "nil"
- local cont = false
- while cont == false do
- userInput = read()
- if userInput == "y" then
- makeFarm = false
- cont = true
- elseif userInput == "n" then
- makeFarm = true
- cont = true
- else
- print("Invalid input, please try again.")
- end
- end
- end
- function setup() --Prepares to build farm
- print("Place the following in the inventory:")
- print("-------------------------------------")
- print("> 13 misc. building blocks....slot 01")
- print("> 1 lava bucket...............slot 02")
- print("> 1 water bucket..............slot 03")
- print("> 3 chests....................slot 04")
- print("> 1 redstone lamp/torch.......slot 05")
- print("> 1 coal......................slot 06")
- print("Hit <Enter> when ready!")
- local input = "nil"
- while input == "nil" do
- input = read()
- end
- print("Now ready to construct cobble farm.")
- end
- function fillUp() --Fill 'er up!
- turtle.select(6)
- turtle.refuel()
- end
- function place(blocks) --Moves forward & places block beneath
- for i=1,blocks,1 do
- turtle.forward()
- turtle.placeDown()
- end
- end
- function dig(blocks) --Digs forward; can deal with cobble/sand
- for i=1,blocks,1 do
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- while turtle.detectUp() do
- turtle.digUp()
- end
- end
- end
- function deposit() --Deposits cobble when inventory is full
- print("Inventory full. Depositing cobble.")
- for slot=1,16,1 do
- turtle.select(slot)
- if turtle.getItemCount(slot) ~= 0 then
- chestFull = not turtle.dropDown()
- end
- end
- turtle.select(1)
- print("Cobble Mined: "..runningTotal)
- end
- function compressCobble() --Compresses cobble from below chest
- print("Beginning compression process.")
- turtle.turnRight()
- turtle.turnRight()
- for stack=1,3,1 do
- print("Building recipie for compressed cobble")
- print("Stack "..stack.." of 3.")
- for slot=1,3,1 do
- turtle.select(slot)
- turtle.suckDown()
- end
- for slot=5,7,1 do
- turtle.select(slot)
- turtle.suckDown()
- end
- for slot=9,11,1 do
- turtle.select(slot)
- turtle.suckDown()
- end
- turtle.craft(64)
- print("Compressed cobble crafted.")
- print("Depositing compressed cobble.")
- turtle.select(11)
- turtle.drop()
- end
- turtle.turnRight()
- turtle.turnRight()
- print("Resuming mining.")
- end
- function constructFarm() --Builds farm
- fillUp()
- print("Now building structure.")
- --Clearing area
- turtle.turnLeft()
- dig(2)
- turtle.turnRight()
- turtle.turnRight()
- dig(5)
- turtle.turnLeft()
- dig(1)
- turtle.turnLeft()
- dig(5)
- turtle.turnRight()
- dig(1)
- turtle.turnRight()
- dig(5)
- turtle.turnRight()
- dig(2)
- turtle.turnRight()
- dig(3)
- turtle.turnLeft()
- dig(1)
- turtle.turnRight()
- dig(1)
- turtle.back()
- turtle.turnRight()
- turtle.forward()
- --Building outline
- turtle.up()
- turtle.select(1)
- turtle.turnLeft()
- place(2)
- turtle.turnRight()
- place(2)
- turtle.turnRight()
- place(5)
- turtle.turnRight()
- place(2)
- turtle.turnRight()
- place(3)
- turtle.turnRight()
- turtle.down()
- --Placing non-compressed cobble chest
- turtle.digDown()
- turtle.select(4)
- turtle.placeDown()
- --Placing Water and then Lava
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- turtle.digDown()
- turtle.select(3) --Water
- turtle.place()
- turtle.turnRight()
- turtle.turnRight()
- turtle.forward()
- turtle.select(2) --Lava
- turtle.place()
- turtle.turnRight()
- turtle.back()
- --Placing Chest for compressed cobble
- turtle.back()
- turtle.turnLeft()
- turtle.select(4)
- turtle.place()
- turtle.turnLeft()
- turtle.back()
- turtle.place()
- --Placing redstone torch
- turtle.turnRight()
- turtle.up()
- turtle.select(5)
- turtle.place()
- turtle.turnRight()
- turtle.down()
- print("Construction complete.")
- print("Now depositing building materials.")
- --Depositing all items
- turtle.turnRight()
- turtle.turnRight()
- for i=1,16,1 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(1)
- turtle.turnRight()
- turtle.turnRight()
- print("Now beginning mining.")
- end
- function mineCobble() --As long as Slot 16 is not full, continues to mine Cobble
- rs.setOutput("left", false)
- while chestFull == false do
- turtle.select(1)
- if turtle.dig() then
- runningTotal = runningTotal + 1
- end
- if firstDeposit == false then
- if turtle.getItemCount(16) == 64 then
- deposit()
- firstDeposit = true
- end
- elseif firstDeposit == true then
- if turtle.getItemCount(11) == 64 then
- deposit()
- compressCobble()
- firstDeposit = false
- end
- end
- end
- end
- function run() --All commands are executed in this function
- shell.run("clear")
- decideToMake()
- if makeFarm == true then
- setup()
- constructFarm()
- end
- shell.run("clear")
- print("MINING LOG:")
- print("-------------------------------------")
- mineCobble()
- print("Chest is full! Done mining.")
- rs.setOutput("left", true)
- end
- --Execution
- run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement