Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --todo:
- -- add function that makes sure that seeds are in the two first slots and they are a stack worth if not, will take two stacks from sorted chest
- -- add command in farmblock for tilling land for non fertilized
- function refuel()
- empty()
- print("refueling")
- if turtle.getFuelLevel() <= 500 then
- print("Refueling... amt 1000")
- turtle.turnLeft()
- turtle.select(3)
- turtle.suck()
- turtle.refuel()
- turtle.turnLeft()
- turtle.drop()
- turtle.turnLeft()
- end
- end
- function panicCorrection()
- local panicMode = true
- while panicMode do
- local success, data = turtle.inspect()
- if success then
- if data.name == "EnderStorage:enderChest" then
- print("SYSTEM PANIC! RECOVERING")
- turtle.turnRight()
- end
- else
- print("System Recovered.")
- panicMode = false
- turtle.forward()
- end
- end
- end
- function forward(amount)
- local counter = 0
- local amt = tonumber(amount)
- print("forward function")
- while counter < amt do
- turtle.forward()
- counter = counter + 1
- end
- end
- function empty()
- print("Emptying..")
- local slots = 3
- while slots < 17 do
- print("Dropped slot ".. slots)
- turtle.select(slots)
- turtle.drop()
- slots = slots + 1
- end
- print("Empty COMPLETE")
- end
- function reSeed()
- local functionBreak = true
- print("reSeed function")
- while functionBreak do
- local data = turtle.getItemDetail()
- print(data.name)
- turtle.placeDown()
- functionBreak = false
- if data ~= "minecraft:carrot" then
- local currentSlot = turtle.getSelectedSlot()
- if currentSlot < 15 then
- turtle.select(currentSlot + 1)
- else
- turtle.select(1)
- end
- end
- end
- local success, data = turtle.inspectDown()
- if not success then
- turtle.place()
- end
- end
- function farmBlock()
- print("farmblock function")
- local success, data = turtle.inspectDown()
- if success then
- if data.name == "minecraft:carrots" then
- if data.metadata == 7 then
- print("Adult carrot Detected, Chopping and Cropping")
- turtle.digDown()
- reSeed()
- end
- end
- else
- print("No Block...")
- end
- end
- function plantBlock()
- print("farmblock function")
- local success, data = turtle.inspectDown()
- if success==false then
- print("Empty plot detected, hoeing and planting")
- turtle.digDown()
- reSeed()
- else
- print("No Block...")
- end
- end
- function detectDirection(currentBlock)
- print("Detect direction function")
- if (currentBlock.W % 2 == 0) then
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- else
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- end
- end
- function main(xy)
- local success, data = turtle.inspect()
- if success then
- if data.name == "EnderStorage:enderChest" then
- panicCorrection()
- end
- end
- print(xy.l)
- print(xy.w)
- local length = xy.l
- local width = xy.w
- local currentBlock= {L = 0, W = 0}
- while currentBlock.W < width do
- currentBlock.L = 0
- print("Here")
- while currentBlock.L < length do
- turtle.forward()
- if xy.bool == true then
- plantBlock()
- else
- farmBlock()
- end
- currentBlock.L = currentBlock.L + 1
- end
- detectDirection(currentBlock)
- farmBlock()
- currentBlock.W = currentBlock.W + 1
- end
- local toggled = true
- while toggled do
- if (currentblockw % 2 == 0) then
- print("dirt detected")
- turtle.turnRight()
- forward(width)
- toggled=false
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- else
- print("stone detected")
- turtle.turnLeft()
- forward(length)
- turtle.turnLeft()
- forward(width)
- turtle.forward()
- toggled=false
- end
- end
- else
- turtle.turnLeft()
- turtle.turnRight()
- refuel()
- turtle.turnRight()
- turtle.forward()
- xy.bool == false
- main(xy)
- end
- function startup()
- term.clear()
- print("#######################################")
- print("#######################################")
- print("#######################################")
- print("##########Blims Farming Turtle#########")
- print("#######################################")
- print("#######################################")
- print("#######################################")
- print("###########ver 1.2-12##################")
- print("#######################################")
- print("#######################################")
- print("#######################################")
- print("#######################################")
- print("#######################################")
- sleep(5)
- term.clear()
- local time = os.time()
- local formattedTime = textutils.formatTime(time, false)
- print("Session Time Begin: ".. formattedTime)
- local xy = {l=0, w=0, bool=false}
- print("To begin, we need to specify the dimensions of the mining turtle...")
- print("Enter the length of perimeter the turtle is working:")
- local length = read()
- print("Enter the width of perimeter the turtle is working:")
- local width = read()
- print("Would you like for the first run to autoplant? (y/n):")
- local boole = read()
- xy.l = tonumber(length)
- if boole = "y" then
- xy.bool = true
- else
- xy.bool = false
- end
- xy.w = tonumber(width)
- if length == width then
- print("This farming turtle will work within a ".. length.. " by ".. width.. " square")
- print("The work area of the turtle should look like this in the example square:")
- print("P= plant export | T = turtle | E= empty fuel bucket | F= full fuel buckets")
- print("######")
- print("######")
- print("######")
- print("######")
- print("######")
- print("PTE###")
- print(" F")
- else
- print("This farming turtle will work within a ".. length.. " by ".. width.. " rectangle")
- print("The work area of the turtle should look like this in the example square:")
- print("P= plant export | T = turtle | E= empty fuel bucket | F= full fuel buckets")
- print("######")
- print("######")
- print("######")
- print("######")
- print("######")
- print("PTE###")
- print(" F")
- end
- refuel()
- print(xy.l)
- print(xy.w)
- sleep(3)
- turtle.forward()
- main(xy)
- end
- startup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement