Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local cache = 0
- local cachemov = 2
- local x,y,z = 0,0,0
- local x1,y1,z1 = 0,0,0
- local x2,y2,z2 = 0,0,0
- local facing = 0
- function ref()
- if turtle.getFuelLevel() < 2 then
- turtle.refuel()
- end
- end
- function explore()
- while (x < x1) or (x > x2) do
- print("limiteX")
- if (x < x1+2) and (x < x2+2) then
- if facing%4 == 3 then
- moveF()
- else
- turtle.turnLeft()
- facing = facing + 1
- end
- end
- if (x > x1-2) and (x > x2-2) then
- if facing%4 == 1 then
- moveF()
- else
- turtle.turnLeft()
- facing = facing + 1
- end
- end
- end
- while (z < z1) or (z > z2) do
- print("limiteZ")
- if (z < z1+2) and (z < z2+2) then
- if facing%4 == 0 then
- moveF()
- else
- turtle.turnLeft()
- facing = facing + 1
- end
- end
- if (z > z1-2) and (z > z2-2) then
- if facing%4 == 2 then
- moveF()
- else
- turtle.turnLeft()
- facing = facing + 1
- end
- end
- end
- if turtle.detectUp() then
- if y < y2 then
- cachemov = 1
- turtle.digUp()
- end
- end
- if cachemov == 1 then
- turtle.up()
- y = y + 1
- cache = 0
- cachemov = 0
- end
- if turtle.dig() then
- cache = 0
- turtle.dig()
- moveF()
- else
- turtle.turnLeft()
- facing = facing + 1
- cache = cache + 1
- end
- if cache >= 4 then
- if y > 64 then
- if turtle.detectDown() then
- if turtle.digDown() then
- y = y - 1
- end
- else
- if turtle.down() then
- y = y - 1
- end
- end
- end
- cache = 0
- end
- end
- function moveF()
- if turtle.forward() then
- if facing%4 == 0 then
- z = z + 1
- end
- if facing%4 == 3 then
- x = x + 1
- end
- if facing%4 == 2 then
- z = z - 1
- end
- if facing%4 == 1 then
- x = x - 1
- end
- --turtle.forward()
- end
- end
- while true do
- term.clear()
- print("\n")
- print(x)
- print("\n")
- print(y)
- print("\n")
- print(z)
- while cachemov == 2 do
- print("\nInserte coordena X :")
- x = tonumber(read())
- print("\nInserte coordena Y :")
- y = tonumber(read())
- print("\nInserte coordena Z :")
- z = tonumber(read())
- print("\nInserte coordena +X:")
- x2= tonumber(read())
- print("\nInserte coordena +Y:")
- y2= tonumber(read())
- print("\nInserte coordena +Z:")
- z2= tonumber(read())
- print("\nInserte hacia donde se dirije la cara (0N 3E 2S 1O):")
- facing = tonumber(read())
- sleep(0)
- x1 = x
- y1 = y
- z1 = z
- cachemov = 0
- end
- ref()
- explore()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement