Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- args={...}
- if (#args < 1) then
- print("Usage: <programname> striplength")
- return
- end
- function empty()
- turtle.select(16)
- turtle.digDown()
- turtle.placeDown()
- for i = 1, 15, 1 do
- turtle.select(i)
- turtle.dropDown()
- end
- turtle.select(1)
- end
- function forward()
- while (turtle.forward() ~= true) do
- if (turtle.detect()) then
- turtle.dig()
- else
- turtle.attack()
- end
- end
- end
- function dig()
- if (turtle.detectUp()) then
- turtle.digUp()
- end
- if (turtle.detect()) then
- turtle.dig()
- end
- forward()
- end
- turnLeft = true
- i_max = tonumber(args[1])
- j_max = 3
- while (turtle.detect() ~= true) do
- forward()
- end
- while (true) do
- j = 1
- while (j <= j_max) do
- dig()
- j = j + 1
- end
- for k = 1, 2, 1 do
- if (turnLeft) then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- i = 1
- while (i <= i_max) do
- turtle.select(16)
- if (turtle.getItemCount() < 2) then
- break
- end
- turtle.select(15)
- if (turtle.getItemCount() > 0) then
- empty()
- end
- turtle.select(1)
- if (turtle.getFuelLevel() <= 100) then
- break
- end
- while (i <= i_max and turtle.detect() ~= true) do
- forward()
- i = i + 1
- end
- dig()
- i = i + 1
- end
- turtle.turnLeft()
- turtle.turnLeft()
- i = 1
- while (i <= i_max) do
- forward()
- i = i + 1
- end
- if (turnLeft) then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- turnLeft = not turnLeft
- end
- turtle.select(16)
- if (turtle.getItemCount() < 2) then
- break
- end
- if (turtle.getFuelLevel() <= 100) then
- break
- end
- print("Done with strip, fuel level:")
- print(turtle.getFuelLevel())
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement