Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- local args1 = tonumber(tArgs[1])
- local args2 = tonumber(tArgs[2])
- local args3 = tonumber(tArgs[3])
- local cDir = "north"
- local cX = 0
- local cY = 0
- local cZ = 0
- local home = {cY,cX,cZ}
- local blocks = "blocks"
- function turnRight()
- if cDir == "north" then
- cDir = "east"
- elseif cDir == "east" then
- cDir = "south"
- elseif cDir == "south" then
- cDir = "west"
- elseif cDir == "west" then
- cDir = "north"
- else
- print("Error!!")
- error()
- end
- turtle.turnRight()
- end
- function turnTo(dir)
- if cDir ~= dir then
- repeat
- turnRight()
- until cDir == dir
- end
- end
- function moveForward()
- if cDir == "north" then
- cX = cX+1
- elseif cDir == "east" then
- cZ = cZ+1
- elseif cDir == "south" then
- cX = cX-1
- elseif cDir == "west" then
- cZ = cZ-1
- else
- print("Error!!")
- error()
- end
- while not turtle.forward() do
- turtle.dig()
- end
- end
- function moveUp()
- cY = cY+1
- while not turtle.up() do
- turtle.digUp()
- end
- end
- function moveDown()
- cY = cY-1
- while not turtle.down() do
- turtle.digDown()
- end
- end
- function moveToX(x)
- if cX < x then
- turnTo("north")
- repeat
- moveForward()
- until cX == x
- elseif cX > x then
- turnTo("south")
- repeat
- moveForward()
- until cX == x
- else
- --print("already there")
- end
- end
- function moveToZ(z)
- if cZ < z then
- turnTo("east")
- repeat
- moveForward()
- until cZ == z
- elseif cZ > z then
- turnTo("west")
- repeat
- moveForward()
- until cZ == z
- else
- --print("already there")
- end
- end
- function moveToY(y)
- if cY < y then
- repeat
- moveUp()
- until cY == y
- elseif cY > y then
- repeat
- moveDown()
- until cY == y
- else
- --print("already there")
- end
- end
- function goTo(x, y, z)
- moveToX(x)
- moveToY(tonumber(y))
- moveToZ(tonumber(z))
- turnTo("north")
- end
- function sayMoveX()
- if args1 == 1 or args1 == -1 then
- blocks = "block"
- else
- blocks = "blocks"
- end
- if args1 > 0 then
- print("I have moved "..tArgs[1].." "..blocks.." forward.")
- elseif args1 < 0 then
- local x = args1*-1
- print("I have moved "..x.." "..blocks.." backwards.")
- else
- print("I haven't moved forward or backwards.")
- end
- end
- function sayMoveY()
- if args2 == 1 or args2 == -1 then
- blocks = "block"
- else
- blocks = "blocks"
- end
- if args2 > 0 then
- print("I have moved "..args2.." "..blocks.." up.")
- elseif args2 < 0 then
- local y = args2*-1
- print("I have moved "..y.." "..blocks.." down.")
- else
- print("I haven't moved up or down.")
- end
- end
- function sayMoveZ()
- if args3 == 1 or args3 == -1 then
- blocks = "block"
- else
- blcoks = "blocks"
- end
- if args3 > 0 then
- print("I have moved "..args3.." "..blocks.." to the right.")
- elseif args3 < 0 then
- local z = args3*-1
- print("I have moved "..z.." "..blocks.." to the left.")
- else
- print("I haven't moved to the right or left.")
- end
- end
- function sayMoves()
- sayMoveX()
- sayMoveY()
- sayMoveZ()
- end
- goTo(args1,args2,args3)
- sayMoves()
- --sleep(5)
- --goTo(home[1],home[2],home[3])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement