This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
sylta's profile picture

trutle cordination fail

Started by sylta, 18 December 2013 - 07:43 AM
sylta #1
Posted 18 December 2013 - 08:43 AM
hi

I followd a toturial for programing turtle for digging whit cordination, and he was using computercraft 1.3 I belive. and i have 1.5. what I found out is that ther are different ways to program for 1.3 and 1.5. here is the link to the toturial: http://www.youtube.com/watch?v=CORN_u7TASI

my turtle just spins to the right

my program:
xCoord = 230
zCoord = 231
yCoord = 75

orientation = 3
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 = orientaion +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()
move = false
while not (moved) do
moved = turtle.forward()
print"I tried to move"
end
print"I moved"
end
function moveUp()
yCoord = yCoord + 1
moved = false
while not (moved) do
moved = turtle.up()
end
end

function moveDown()
yCoord =yCoord -1
turtle.digDown()
moved = false
while not (moved) do
moved = turtle.down()
end
end

function look(direction)
while direction ~= orientations[orientation] do
right()
end
end

function goto(xTarget, zTarget, yTarget)
if yTarget < yCoord then
moveDown()
end
while yTarget > yCoord do
moveUp()
end
if xTarget < xCoord then
look("west")
while xTarget < xCoord do
moveForward()
end
end
if xTarget > xCoord then
look("east")
while xTarget >xCoord do
move Forward()
end
end
if zTarget < zCoord then
lokk("northe")
while zTarget < zCoord do
moveForward()
end
end
end
goto(264, 230, 76)
Lyqyd #2
Posted 18 December 2013 - 10:17 AM
Did you put fuel in the turtle? The code should work just as well as it worked in previous versions.
TheOddByte #3
Posted 18 December 2013 - 11:08 AM
Uhmm why don't you have '{}' around the orientations?

orientations = { "north", "east", "south", "west" }
Do the same for zDiff and xDiff.

Other than that I can't see any problems, Also use code tags when posting [.CODE] <Code here> [./CODE] ( Without the dots )
Edited on 18 December 2013 - 10:09 AM