Posted 23 June 2013 - 12:37 AM
I'm following a tutorial video that is teaching me to write a simple(ish) program to have the turtle move forward three blocks, then record its location. It is very much a WIP, I just want to know what the problem is. It is on the 28th line of this code:
xCoord = -479
zCoord = -20
yCoord = 66
orientation = 4
orientations = {"north", "east", "south", "west"}
local zDiff = {-1, 0, 1, 0}
local 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] -- <--- This line
zCoord = zCoord + zDiff[orientation]
turtle.forward()
end
for i = 1,3 do
moveForward()
print("X: "..xCoord.." Z: "..zCoord)
end
Edited by