Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ____ ____ _ _ ____ _ _ ____ ____ ____ ____
- -- [__ |___ | | |___ |\ | [__ |___ |__| [__ ____ ____ ____ ___ ____ __ _ ___ ____ ____
- -- ___] |___ \/ |___ | \| ___] |___ | | ___] |___ [__] |--< |--' |--| | \| |__> |___ [__]
- --
- --
- -- NOTES :
- -- This program must achieve the following.
- -- 1) Maintain the ability to dig a straight tunnel without fail.
- -- 2) Lighting the tunnel in order on maintain a safe work environment.
- -- 3) Return to a drop off point when the turtle detects a full load.
- --
- -- VARIABLES --
- interval = 100 -- User input.
- loop = 0
- turtleDetect = turtle.detect()
- turtleDirection = 1 -- 1 is forward; 0 is left; 2 is right.
- turtlePosition = 0 -- 0 is defined as lower position whereas 1 is defined as the higher position.
- -- FUNCTIONS --
- function checkInventory(x)
- turtle.select(16)
- if (turtle.getItemCount() > 0) then
- if (turtleDirection == 0) then
- turtle.turnLeft()
- elseif (turtleDirection == 1) then
- turtle.turnLeft()
- turtle.turnLeft()
- elseif (turtleDirection == 2) then
- turtle.turnRight()
- end
- for i=0,x do
- turtle.forward()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- exit()
- else
- turtle.select(1)
- end
- end
- function turtleDig(x)
- turtle.dig()
- checkInventory(x)
- sleep(.15)
- if (turtleDetect == true) then
- turtle.dig()
- end
- end
- function turtleDigRow(x)
- turtle.turnRight()
- turtleDirection = 2
- turtleDig(x)
- turtle.turnLeft()
- turtleDirection = 1
- turtleDig(x)
- turtle.turnLeft()
- turtleDirection = 0
- turtleDig(x)
- turtle.turnRight()
- turtleDirection = 1
- end
- function turtleDigFunction(x)
- if (turtlePosition == 0) then
- turtleDigRow(x)
- turtle.digUp()
- turtle.up()
- turtlePosition = 1
- elseif (turtlePosition == 1) then
- turtleDigRow(x)
- turtle.digUp()
- turtle.up()
- turtlePosition = 2
- elseif (turtlePosition == 2) then
- turtleDigRow(x)
- turtle.forward()
- turtle.digDown()
- turtle.down()
- turtle.digDown()
- turtle.down()
- turtlePosition = 0
- end
- end
- -- // MAIN SCRIPT //
- while (loop < interval) do
- turtleDigFunction(loop)
- loop = loop + 1
- end
- turtle.turnRight()
- turtle.turnRight()
- for i=0, interval do
- turtle.forward()
- turtle.turnRight()
- turtle.turnRight()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement