Posted 22 January 2014 - 12:12 AM
Please help me understand the highlighted code, especially relationship between "xDiff[orientation]" and "xDiff = {0, 1, 0, -1}" I understand how he got the xDiff table.
http://www.youtube.com/watch?v=S6k88NnotM4
http://www.youtube.com/watch?v=S6k88NnotM4
xCoord = 8809
yCoord = 65
zCoord = -2582
orientation = 4
orientations ={"North", "East", "South", "West"}
zDiff = {-1, 0, 1, 0}
xDiff = {0, 1, 0, -1}
function left()
orientation = orientation - 1
orientation = (orientation -1) % 4
orientation = orientation + 1
turtle.turnLeft()
end
function right()
orientation = orientation - 1
orientation = (orientation +1) % 4
orientation = orientation + 1
turtle.turnRight()
end
function moveForward()
xCoord = xCoord + xDiff[orientation]
zCoord = zCoord + zDiff[orientation]
turtle.dig()
moved = false
while not(moved) do
moved = turtle.forward()
end
end
for i = 1, 3 do
moveForward()
print("X: ".. xCoord.. " Z: "..zCoord.. "Y: "..yCoord)
end