Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- TurtleBotania
- -- DEBUG
- DEBUG = true
- if DEBUG then
- print("[[DEBUG] Start of turtleBotania")
- end
- -- setup - path the turtle follow hovering living stone/livingwood
- -- [.] = glass: [x] = chest / interface; [p] = pure daisy;
- -- > < \/ /\ = path of the turtle
- --
- -- Top view
- --
- -- [.][.][.][.][.]
- -- [.] > [.]
- -- [.][.][.] /\[P]\/ [.]
- -- [x] < < [.]
- -- [.] \/[P] /\[.][.][.]
- -- [.] > [.]
- -- [.][.][.][.][.]
- --
- -- slot 1 coal to fuel
- -- slot 2 living stone
- -- slot 3 living wood
- -- slot 4 glass
- -- make sure coal is available on the chest
- -- and to extract livingwood/stone
- function isItStoneOrWood()
- if DEBUG then
- print("[[DEBUG] Start of isItStoneOrWood")
- end
- res = false
- turtle.select(2)
- res = turtle.compareDown()
- if res then
- return res
- end
- turtle.select(3)
- res = turtle.compareDown()
- return res
- end
- function routine()
- if DEBUG then
- print("[[DEBUG] Start of routine")
- end
- mvt = true
- while mvt do
- mvt = turtle.forward()
- if isItStoneOrWood() then
- turtle.digDown()
- end
- end
- end
- function refuelAndUnload()
- if DEBUG then
- print("[[DEBUG] Start of refuelAndUnload")
- end
- turtle.select(1)
- turtle.suck()
- if (turtle.getItemCount(1) > 7) then
- turtle.refuel(7)
- end
- turtle.select(2)
- turtle.drop(turtle.getItemCount(2)-1)
- turtle.select(3)
- turtle.drop(turtle.getItemCount(3)-1)
- end
- function findDaWay()
- if DEBUG then
- print("[[DEBUG] Start of findDaWay")
- end
- -- 1st case the block in front is glass
- -- if the right block is glass path if left
- -- else the path is right
- -- 2nd case can't go forward and block in front isn't glass
- -- refuel and unload and path is in the left
- turtle.select(4)
- if turtle.compare() then
- -- check right block
- turtle.turnRight()
- if DEBUG then
- print("[DEBUG] did i bugged here ?")
- end
- if turtle.compare() then
- turtle.turnLeft()
- turtle.turnLeft()
- end
- else
- refuelAndUnload()
- turtle.turnLeft()
- end
- end
- while true do
- routine()
- findDaWay()
- end
Advertisement
Add Comment
Please, Sign In to add comment