Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- turtleplaceitem
- --- simple program to automate crop sticks
- width = 8
- length = 8
- lastmoveok = true
- for l=1,length,1 do
- for w=1,width,1 do
- turtle.placeDown()
- lastmoveok=turtle.forward()
- end
- -- undo the last forward, if it happened ok
- if lastmoveok == true
- turtle.back()
- end
- -- to save the hastle of going back [w] spaces and shifting over a block
- -- which consumes double the fuel, conserve by interleaving:
- failcount=0
- if ( l % 2 ) == 0 then
- if turtle.turnLeft() then failcount=failcount+1; end
- if turtle.forward() then failcount=failcount+1; end
- if turtle.turnLeft() then failcount=failcount+1; end
- else
- if turtle.turnRight() then failcount=failcount+1; end
- if turtle.forward() then failcount=failcount+1; end
- if turtle.turnRight() then failcount=failcount+1; end
- end
- -- if any of the above failed, we need to stop, the turtle is either
- -- obstructed or out of fuel
- if failcount > 0 then
- -- do not check zero fuel level in case cheat or other alternative is active
- -- let turtle run if it CAN run (not reposnsible for players that take advantage)
- if turtle.getFuelLevel() == 0 then
- -- strictly for info purposes only
- print("out of fuel, aborting")
- else
- print("turtle obstructed, aborting")
- end
- break
- else
- print("this run is aok, starting next run, if any")
- end
- -- ready for next run
- end
- print("completed run exiting program")
- print("remaining fuel: " .. turtle.getFuelLevel() );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement