Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- waitTime = 300 -- time to wait before reruning the program
- function menu()
- term.clear()
- term.setCursorPos(1,1)
- print("--------------------")
- print("Welcome To FarmBotOS")
- print("--------------------")
- print("Press Enter To Start Farming")
- print("Press RShift To Make A Farm")
- print("Press H For Help")
- print("Press Backspace To Cancel")
- while true do
- local event, key = os.pullEvent( "key" ) -- limit os.pullEvent to the 'key' event
- if key == keys.enter then -- if the key pressed was 'Enter'
- farm()
- break
- end
- if key == keys.rightShift then -- if the key pressed was 'RShift'
- makeFarm()
- break
- end
- if key == keys.h then -- if the key pressed was 'H'
- term.clear()
- term.setCursorPos(1,1)
- helpPageOne()
- break
- end
- if key == keys.backspace then -- if the key pressed was 'Backspace'
- term.clear()
- term.setCursorPos(1,1)
- break
- end
- end
- end
- function helpPageOne()
- print("----------------------")
- print("Where Do You Put Items")
- print("----------------------")
- print("Slot 1: Fuel (DON'T USE LAVA!)")
- print("For Making The Farm:")
- print("Slot 13: Water Bucket")
- print("Slot 14: Water Bucket")
- print("Slot 15: Diamond Shovel (MUST BE DIAMOND!)")
- print("Slot 16: 3 Chests")
- print("Press -> For Next Page, Or Backspace To Cancel")
- while true do
- local event, key = os.pullEvent( "key" ) -- limit os.pullEvent to the 'key' event
- if key == keys.right then -- if the key pressed was '->'
- term.clear()
- term.setCursorPos(1,1)
- helpPageTwo()
- break
- end
- if key == keys.backspace then -- if the key pressed was 'backspace'
- term.clear()
- term.setCursorPos(1,1)
- menu()
- break
- end
- end
- end
- function helpPageTwo()
- print("----------------------")
- print("What Chests Hold What")
- print("----------------------")
- print("Chests Numbered From Left To Right Looking At The Backs Of The Chests")
- print("Chest 1: Fuel")
- print("Chest 2: Wheat")
- print("Chest 3: Seeds")
- print("Press Backspace To Cancel")
- while true do
- local event, key = os.pullEvent( "key" ) -- limit os.pullEvent to the 'key' event
- if key == keys.backspace then -- if the key pressed was 'backspace'
- term.clear()
- term.setCursorPos(1,1)
- menu()
- break
- end
- end
- end
- function farm()
- turtle.up()
- turtle.forward()
- turtle.turnRight()
- inspectFarm()
- for f = 1, 36 do
- turtle.forward()
- end
- turtle.down()
- refuelFromChest()
- depositWheatAndSeeds()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- os.sleep(waitTime)
- farm()
- end
- function inspectFarm()
- inspectFarmSection()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- inspectFarmSection()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- inspectFarmSection()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- inspectFarmSection()
- turtle.turnLeft()
- end
- function inspectFarmSection()
- inspectRow()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- inspectRow()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- inspectRow()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- inspectRow()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- inspectRow()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- inspectRow()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- inspectRow()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- inspectRow()
- end
- function inspectRow()
- for r = 1, 7 do
- inspectWheat()
- turtle.forward()
- end
- inspectWheat()
- end
- function inspectWheat()
- local success, data = turtle.inspectDown()
- if success then
- if data.name == "minecraft:wheat" then
- if data.metadata == 7 then
- turtle.digDown()
- turtle.digDown()
- plantSeed()
- end
- end
- else
- turtle.digDown()
- turtle.digDown()
- plantSeed()
- end
- end
- function plantSeed()
- for b = 1, 16 do
- if turtle.getItemCount(b) ~= 0 then
- if turtle.getItemDetail(b).name == "minecraft:wheat_seeds" then
- turtle.select(b)
- turtle.placeDown()
- return
- end
- end
- end
- end
- function refuelFromChest()
- turtle.select(1)
- while turtle.getFuelLevel() < 800 do
- turtle.refuel(1)
- end
- while turtle.getItemSpace() > 32 do
- turtle.suck(1)
- end
- return
- end
- function depositWheatAndSeeds()
- turtle.turnLeft() -- Move turtle toward the wheat chest
- turtle.forward()
- turtle.turnRight() -- face the wheat chest
- turtle.select(1)
- for s = 1, 16 do
- if turtle.getItemCount(s) ~= 0 then
- if turtle.getItemDetail(s).name == "minecraft:wheat" then
- turtle.select(s)
- turtle.drop()
- end
- end
- end
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- for v = 1, 16 do
- if turtle.getItemCount(v) ~= 0 then
- if turtle.getItemDetail(v).name == "minecraft:wheat_seeds" then
- turtle.select(v)
- turtle.drop()
- end
- end
- end
- end
- function makeFarm()
- if turtle.getFuelLevel() < 800 then
- print("[ERROR] Not Enough Fuel! Refuel Me To 800 Then Re-Run The Program")
- return
- end
- turtle.select(16) -- select the chests
- turtle.turnRight()
- turtle.turnRight()
- turtle.place() -- place the coal chest
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- turtle.place() -- place the wheat chest
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- turtle.place() -- place the seeds chest
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.turnRight() -- back at start position
- turtle.select(15) -- select the diamond shovel
- turtle.equipLeft() -- equip the shovel
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.turnRight() -- position turtle in front of water row
- digAndFillWaterRow()
- turtle.turnRight()
- forward(9)
- turtle.turnRight()
- digAndFillWaterRow()
- turtle.turnRight()
- forward(9)
- turtle.turnRight()
- digAndFillWaterRow()
- turtle.turnRight()
- forward(9)
- turtle.turnRight()
- digAndFillWaterRow()
- turtle.turnLeft()
- turtle.select(15) -- select the hoe
- turtle.equipLeft()
- forward(34)
- turtle.turnRight()
- for c = 2, 16 do
- turtle.select(c)
- turtle.drop()
- end
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- turtle.up()
- tillFarm()
- for f = 1, 36 do
- turtle.forward()
- end
- turtle.down()
- refuelFromChest()
- depositWheatAndSeeds()
- getSeeds()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- farm()
- end
- function digAndFillWaterRow()
- for d = 1, 7 do
- turtle.digDown()
- turtle.forward()
- end
- turtle.digDown()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(14) -- select the water bucket
- turtle.placeDown()
- turtle.forward()
- turtle.forward()
- turtle.select(13)
- turtle.placeDown()
- turtle.back()
- turtle.placeDown()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.placeDown()
- turtle.back()
- turtle.placeDown()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.placeDown()
- turtle.back()
- turtle.placeDown()
- turtle.forward()
- turtle.forward()
- turtle.placeDown()
- turtle.back()
- turtle.select(14)
- turtle.placeDown()
- os.sleep(3)
- turtle.select(13)
- turtle.placeDown()
- turtle.forward()
- turtle.select(13)
- end
- function tillFarm()
- tillFarmSection()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- tillFarmSection()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- tillFarmSection()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- tillFarmSection()
- turtle.turnLeft()
- end
- function tillFarmSection()
- tillRow()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- tillRow()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- tillRow()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- tillRow()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- tillRow()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- tillRow()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- tillRow()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- tillRow()
- end
- function tillRow()
- for r = 1, 7 do
- turtle.digDown()
- turtle.forward()
- end
- turtle.digDown()
- end
- function getSeeds()
- turtle.select(2)
- while turtle.getItemSpace() > 0 do
- turtle.suck(4)
- end
- turtle.select(3)
- while turtle.getItemSpace() > 0 do
- turtle.suck(4)
- end
- turtle.select(4)
- while turtle.getItemSpace() > 0 do
- turtle.suck(4)
- end
- turtle.select(5)
- while turtle.getItemSpace() > 0 do
- turtle.suck(4)
- end
- end
- function forward(d)
- for i = 1, d do
- turtle.forward()
- end
- end
- menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement