Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- 0 = Return, 1 = Maintenance, 2 = Farming, 3 = Critical
- local status = 0
- local row = 3
- local stepsToGo = 8
- local stepsSoFar = 0
- --Return to station
- function Return()
- if status == 0 then
- local front = GetBlock(1)
- local under = GetBlock(3)
- if front == "minecraft:chest" and under == "minecraft:chest" then
- turtle.turnLeft()
- turtle.turnLeft()
- status = 1
- elseif under == "minecraft:chest" and front ~="minecraft:chest" then
- turtle.turnLeft()
- elseif front == "botania:flower" then
- turtle.dig()
- turtle.forward()
- elseif front == "botania:specialflower" then
- turtle.turnLeft()
- elseif front == "minecraft:chest" and under == "minecraft:stone" then
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- status = 1
- else
- local under = GetBlock(3)
- if under == "minecraft:stone" or under == "minecraft:grass" then
- turtle.forward()
- elseif under == "minecraft:cobblestone" then
- turtle.back()
- turtle.turnLeft()
- else
- status = 3
- end
- end
- end
- end
- -- Inspects the block infront, above or below the turtle.
- function GetBlock(side)
- if side == 1 then
- local s, d = turtle.inspect()
- if s then return d.name else return false end
- elseif side == 2 then
- local s, d = turtle.inspectUp()
- if s then return d.name else return false end
- elseif side == 3 then
- local s, d = turtle.inspectDown()
- if s then return d.name else return false end
- end
- end
- function Refuel()
- print("Refueling..")
- turtle.select(1)
- if not turtle.refuel(3) then
- print("Fuel reserves low.. Returning home")
- status = 0
- end
- end
- function PickFlowers()
- local front = GetBlock(1)
- if front == "botania:flower" then
- turtle.dig()
- turtle.forward()
- elseif front == "botania:specialflower" then
- turtle.turnLeft()
- status = 0
- return
- else
- turtle.forward()
- end
- stepsSoFar = stepsSoFar + 1
- if stepsSoFar == stepsToGo then
- row = row - 1
- turtle.turnLeft()
- stepsSoFar = 0
- end
- if row == 0 then stepsToGo = stepsToGo - 1 end
- print("Togo: " .. stepsToGo .. " SoFar:" .. stepsSoFar .. "N: " .. row)
- end
- function GrabFuel()
- if turtle.getItemCount(1) > 0 then
- if turtle.getItemDetail(1).name ~= "minecraft:coal" then
- print("That's not fuel.. Ew!")
- turtle.select(1)
- turtle.drop()
- end
- end
- if turtle.getItemCount(1) < 16 and status == 1 then
- print("Grabbing Fuel..")
- turtle.select(1)
- turtle.suckDown()
- end
- end
- function DropOff()
- turtle.turnLeft()
- turtle.turnLeft()
- for i=2,16 do
- if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- turtle.dropUp()
- end
- end
- turtle.turnLeft()
- turtle.turnLeft()
- end
- --main loop
- while true do
- if turtle.getFuelLevel() < 10 then
- Refuel()
- end
- if status == 0 then
- print("Finding home..")
- Return()
- end
- if status == 1 then
- n = 3
- stepsToGo = 8
- stepsSoFar = 0
- print("Refueling.. Storing.. Polishing..")
- DropOff()
- GrabFuel()
- print("Maintenance completed!")
- status = 2
- end
- if status == 2 then
- PickFlowers()
- end
- if status == 3 then
- print("Critical error..")
- sleep(20)
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement