Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- local forward = 0
- local right = 0
- local down = 0
- forward = tonumber(tArgs[1])
- right = tonumber(tArgs[2])
- down = tonumber(tArgs[3])
- function moveForward(n)
- for i=1, n do
- while not turtle.forward() do
- turtle.dig()
- turtle.attack()
- end
- end
- end
- function rotateBack()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function checkFull()
- if turtle.getItemCount(16)>0 then
- getBack()
- end
- end
- function checkFuel()
- while true do
- fuel = turtle.getFuelLevel()
- if fuel<(forward*right*depth*20) then
- print("Not enough fuel")
- print("Put fuel in slot 1")
- --turtle.refuel(turtle.getItemCount(1))
- turtle.refuelAll()
- else
- break
- end
- print("Fuel OK")
- sleep(3)
- end
- end
- function getBack(f, r, d, dir)
- if dir==0 then
- rotateBack()
- end
- if d>0 then
- for i=1, d do
- turtle.up()
- end
- end
- if r>0 then
- turtle.turnRight()
- moveForward(r)
- turtle.turnLeft()
- end
- moveForward(f)
- end
- function changeDirection()
- if direction==0 then
- direction = 1
- else
- direction = 0
- end
- end
- --MAIN
- local movedForward = 0
- local movedRight = 0
- local movedDown = 0
- local direction = 0
- if down>0 then
- --checkFuel()
- moveForward(1)
- for d=1, down do
- for r=1, right do
- for f=1, forward-1 do
- print("Kopam naprijed")
- moveForward(1)
- if direction == 0 then
- movedForward = movedForward + 1
- else
- movedForward = movedForward - 1
- end
- end
- if movedRight<right-1 then
- print("Trebam desno")
- if direction==0 then
- print("Okrecem desno")
- turtle.turnRight()
- moveForward(1)
- turtle.turnRight()
- movedRight = movedRight + 1
- changeDirection()
- else
- print("Okrecem lijevo")
- turtle.turnLeft()
- moveForward(1)
- turtle.turnLeft()
- movedRight = movedRight + 1
- changeDirection()
- end
- end
- end
- if movedDown<down-1 then
- print("Idem dole")
- turtle.digDown()
- turtle.down()
- end
- end
- getBack(movedForward, movedRight, movedDown, direction)
- else
- print("Set all parameters: Forward, Right, Down")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement