Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if posx == nil then posx = 1 end
- if posy == nil then posy = 0 end
- if fieldx == nil then fieldx = 9 end
- if fieldy == nil then fieldy = 9 end
- if wait == nil then wait = 420 end
- if waitafter == nil then waitafter = true end
- function refuel()
- if turtle.getFuelLevel() < 150 then
- turtle.select(15)
- turtle.refuel()
- turtle.select(1)
- end
- end
- function coord()
- print("Position: "..posx.." / "..posy)
- end
- function iposx()
- posx = posx + 1
- end
- function iposy()
- posy = posy + 1
- end
- function dposx()
- posx = posx - 1
- end
- function dposy()
- posy = posy - 1
- end
- function mine()
- print("doing stuff here")
- turtle.select(1)
- turtle.placeDown()
- turtle.digDown()
- for i=5,8 do
- turtle.select(i)
- turtle.placeDown()
- end
- turtle.select(1)
- end
- function move(dx, dy)
- --coord()
- if dy >= posy then
- moveDirY(posy, dy)
- moveDirX(posx, dx)
- else
- moveDirX(posx, dx)
- moveDirY(posy, dy)
- end
- coord()
- end
- function moveDirX(ax, dx)
- if ax==dx then return end
- if ax == 0 then step(dx, 0) else
- delta = dx - ax
- step(delta, 0)
- end
- end
- function moveDirY(ay, dy)
- if not (ay==dy) then
- if ay == 0 then step(dy, 1) else
- delta = dy - ay
- step(delta, 1)
- end
- else
- --print("Fuck!")
- end
- end
- function betrag(zahl1)
- if zahl1 < 0 then return zahl1 * -1
- else return zahl1
- end
- end
- function step(count, axis)
- if axis == 0 then
- if count < 0 then
- moveLeft(betrag(count))
- return true
- else
- moveRight(betrag(count))
- return true
- end
- else
- if count > 0 then
- moveForward(betrag(count))
- return true
- else
- moveBack(betrag(count))
- return true
- end
- end
- end
- function moveRight(ci)
- turtle.turnRight(1)
- for i=1, ci do
- print("Moving right. New: "..(posx+1).." / "..posy)
- if not turtle.detect() then
- turtle.forward()
- iposx()
- else print("I crashed right!")
- end
- end
- turtle.turnLeft(1)
- end
- function moveLeft(ci)
- turtle.turnLeft(1)
- for i=1, ci do
- print("Moving left. New: "..(posx-1).." / "..posy)
- if not turtle.detect() then
- turtle.forward()
- dposx()
- else print("I crashed left!")
- end
- end
- turtle.turnRight(1)
- end
- function moveForward(ci)
- for i=1, ci do
- print("Moving forward. New: "..posx.." / "..(posy+1))
- if not turtle.detect() then
- turtle.forward()
- iposy()
- else print("I crashed forward!")
- end
- end
- end
- function moveBack(ci)
- turn180()
- for i=1, ci do
- print("Moving back. New: "..posx.." / "..(posy-1))
- if not turtle.detect() then
- turtle.forward()
- dposy()
- else print("I crashed backward!")
- end
- end
- turn180()
- end
- function turn180()
- turtle.turnRight()
- turtle.turnRight()
- end
- if waitafter then sleep(wait) end
- --move(5,5)
- --move(1,1)
- --move(1,2)
- --move(2,2)
- while turtle.getItemCount(15) >= 1 do
- for i=1, 9 do
- for j=1, 9 do
- if not ((i==4) and (j==5)) then
- move(i,j)
- mine()
- else
- move(i,j)
- end
- end
- refuel()
- end
- move(1,1)
- end
- if waitafter then sleep(wait) end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement