Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- returning = false
- space = 4
- st = 60
- warning = 20
- limit = turtle.getFuelLimit()
- function getFuelPercentage()
- level = turtle.getFuelLevel()
- percentage = (level/limit)*100
- print("fuel at: "..percentage.."%")
- return percentage
- end
- function chop()
- print("Chopping")
- turtle.select(1)
- --sleep(st)
- turtle.turnRight()
- local success, data = turtle.inspect()
- if (success and data.name == "minecraft:log") then
- ----chopping------
- turtle.dig()
- turtle.forward()
- repeat
- local success, data = turtle.inspectUp()
- turtle.digUp()
- turtle.suck()
- turtle.up()
- until data.name ~= "minecraft:log"
- while turtle.down() do
- end
- for i = 1,4 do
- turtle.suck()
- turtle.turnRight()
- end
- turtle.back()
- end
- turtle.place()
- turtle.turnLeft()
- end
- function move()
- --sleep(st)
- for i = 1,space do
- turtle.forward()
- turtle.suck()
- end
- local success, data = turtle.inspect()
- if success then
- print("i see a wall")
- print("Block name: ", data.name)
- rotate()
- return
- end
- print("moving")
- end
- function unload()
- print("Unloading")
- --sleep(st)
- turtle.turnLeft()
- for j = 1,4 do
- turtle.forward()
- for i=1,16 do
- turtle.select(i)
- turtle.dropDown()
- end
- if j == 4 and getFuelPercentage() < warning then
- print("fuel low")
- turtle.select(1)
- turtle.suckDown()
- turtle.refuel()
- end
- end
- for j = 1, 4 do
- turtle.back()
- if j == 1 then
- turtle.select(1)
- turtle.suckDown()
- end
- end
- turtle.turnRight()
- print("sleeping")
- sleep(st)
- end
- function rotate()
- print("Rotating")
- --sleep(st)
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- if returning then
- unload()
- returning = false
- move()
- else
- returning = true
- end
- end
- ----------Main----------
- while true do
- move()
- if not returning then
- chop()
- end
- --print(returning)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement