Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Move on the X axis i.e. East / West
- function move_X(number)
- if(number <= 0) then
- turn("W")
- return true
- elseif(number >= 0) then
- turn("E")
- return true
- else
- return true
- end
- end
- -- Move on the Y axis i.e. Up / Down
- function move_Y(number)
- return true
- end
- -- Move on the Z axis i.e. North / South
- function move_Z(number)
- if(number <= 0) then
- turn("S")
- return true
- elseif(number >= 0) then
- turn("N")
- return true
- else
- return true
- end
- return true
- end
- function turn(newDirection)
- A = {["N"] = {["N"] = 0, ["E"] = 1, ["S"] = 2, ["W"] = 3},
- ["E"] = {["N"] = 3, ["E"] = 0, ["S"] = 1, ["W"] = 2},
- ["S"] = {["N"] = 2, ["E"] = 3, ["S"] = 0, ["W"] = 1},
- ["W"] = {["N"] = 1, ["E"] = 2, ["S"] = 3, ["W"] = 0}
- }
- currentDirection = getFacing()
- if(A[currentDirection][newDirection] == 3) then turtle.turnLeft()
- else
- for 1, A[currentDirection][newDirection] do
- if(A[currentDirection][newDirection]) == 3 then turtle.turnRight() end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement