Posted 06 March 2015 - 01:17 AM
I am trying to make turtles that can see using new command computers, but for some reason whenever I run the turtle code getOrientation always returns 0
Turtle code:
Turtle code:
rednet.open("left")
function getOrientation()
loc1 = vector.new(gps.locate(2, false))
if not turtle.forward() then
for j=1,6 do
if not turtle.forward() then
turtle.dig()
else break end
end
end
loc2 = vector.new(gps.locate(2, false))
heading = loc2 - loc1
return ((heading.x + math.abs(heading.x) * 2) + (heading.z + math.abs(heading.z) * 3))
end
pos = getOrientation()
print(pos)
x, y, z = gps.locate(2)
if pos == 1 then
rednet.send(12, x-1)
rednet.send(12, y)
rednet.send(12, z)
print("1")
elseif pos == 2 then
rednet.send(12, x)
rednet.send(12, y)
rednet.send(12, z-1)
print("2")
elseif pos == 3 then
rednet.send(12, x+1)
rednet.send(12, y)
rednet.send(12, z)
print("3")
elseif pos == 4 then
rednet.send(12, x)
rednet.send(12, y)
rednet.send(12, z+1)
print("4")
end
Does anyone know why?Edited on 06 March 2015 - 12:17 AM