Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- trans={}
- trans[1]="north"
- trans[2]="east"
- trans[3]="south"
- trans[0]="west"
- if #tArgs ~= 8 then
- print("Not enough Arguments")
- error()
- end
- --[[if tArgs[4] ~= "north" then
- elseif tArgs[4] ~= "east" then
- elseif tArgs[4] ~= "south" then
- elseif tArgs[4] ~= "west" then
- for k,v in pairs(trans) do
- if tArgs[4] == k
- then tArgs[4] = v
- end
- end
- else
- print("Argument 4 must be = north, east, south or west.")
- error()
- end]]--
- for k,v in pairs(trans) do
- if tArgs[4] == k
- then tArgs[4] = v
- end
- end
- print(tArgs[4])
- local cDir = tArgs[4]
- local cX = tonumber(tArgs[1])
- local cY = tonumber(tArgs[2])
- local cZ = tonumber(tArgs[3])
- print(cDir)
- function turnRight()
- if cDir == "north" or 1 then
- cDir = "east"
- elseif cDir == "east" or 0 then
- cDir = "south"
- elseif cDir == "south" or 3 then
- cDir = "west"
- elseif cDir == "west" or 2 then
- cDir = "north"
- else
- print("TurnrightError!!")
- return nil
- end
- turtle.turnRight()
- end
- function turnLeft()
- if cDir == "north" or 1 then
- cDir = "west"
- elseif cDir == "east" or 0 then
- cDir = "north"
- elseif cDir == "south" or 3 then
- cDir = "east"
- elseif cDir == "west" or 2 then
- cDir = "south"
- else
- print("TurnLeftError!!")
- return nil
- end
- turtle.turnLeft()
- end
- function turnTo(dir)
- if cDir ~= dir then
- repeat
- turnRight()
- until cDir == dir
- end
- end
- function moveForward()
- if cDir == "north" or 1 then
- cZ = cZ-1
- elseif cDir == "east" or 0 then
- cX = cX+1
- elseif cDir == "south" or 3 then
- cZ = cZ+1
- elseif cDir == "west" or 2 then
- cX = cX-1
- else
- print("forwardError!!")
- return nil
- 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("east")
- repeat
- moveForward()
- until cX == x
- elseif cX > x then
- turnTo("west")
- repeat
- moveForward()
- until cX == x
- else
- --print("already there")
- end
- end
- function moveToZ(z)
- if cZ < z then
- turnTo("south")
- repeat
- moveForward()
- until cZ == z
- elseif cZ > z then
- turnTo("north")
- 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,dir)
- moveToX(x)
- moveToZ(z)
- moveToY(y)
- turnTo(dir)
- end
- goTo(tonumber(tArgs[5]), tonumber(tArgs[6]), tonumber(tArgs[7]), tArgs[8])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement