Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- - StripMiner v0.1 -
- Goals: Will strip mine up to 64 blocks away
- --]]
- -- Starting Location (Base)
- local start_x, start_y, start_z = 634, 10, 1353
- -- Current Location
- local x, y, z = start_x, start_y, start_z
- -- Logic: As long as we're inside of the min and maximums... we're okay.
- while turtle.getFuelLevel() > 1000 and isInventoryFull then
- -- Step 1: Determine if the turtle found a block...
- if turtle.detect() then
- -- It did... Dig it.
- turtle.dig()
- else
- -- It didn't... Move forward.
- turtle.forward()
- x += x
- end
- end
- -- Logic: When its low on fuel or is full... Go back to base by retracing steps.
- while reachedBase == false then
- -- Take the current location and create a loop to go back...
- local isX = false
- -- Determine if the turtle moved in the X or Z location.
- if x > start_x or x < start_x then
- isX = true
- end
- if isX then
- -- They are AHEAD of the start location. Move BACK.
- while x > start_x then
- turtle.back()
- end
- -- They are BEHIND the start location. Move FORWARD.
- while x < start_x then
- turtle.forward()
- end
- end
- if isZ then
- -- They are AHEAD of the start location... Move Back.
- while z > start_z then
- turtle.back()
- end
- -- They are BEHIND the start location... Move Forward.
- while z < start_z then
- turtle.forward()
- end
- end
- rednet.open("right")
- rednet.send(1, "The turtle has ran out of juice.")
- rednet.send(1, "Location: (" .. x .. "," .. y .. "," .. z .. ")")
- rednet.close("right")
- -- Helpful function to handle checking inventory code.
- isInventoryFull = function ()
- -- Search the inventory to see if all spaces are full...
- for i=1, 16 then
- if turtle.getItemCount(i) >= 64 then
- return true
- end
- end
- return false
- end
- -- Helpful function to handle getting back to base.
- reachedBase = function ()
- return x == start_x and z == start_z
- end
Add Comment
Please, Sign In to add comment