Posted 12 March 2013 - 08:30 AM
My head is burning with this code :D/>
Where is the error ? When I turn forward the turtle.. then it doing strange thinks :)/>
Thanks for the help !
Where is the error ? When I turn forward the turtle.. then it doing strange thinks :)/>
Thanks for the help !
rednet.open ("right")
PCID = 21
local positionx = 0
local positiony = 0
local positionz = 0
while true do
id, command = rednet.receive()
if command == "go" then
turtle.forward()
elseif command == "back" then
turtle.back()
elseif command == "left" then
turtle.turnLeft()
elseif command == "right" then
turtle.turnRight()
elseif command == "dig" then
turtle.dig()
elseif command == "up" then
turtle.up()
elseif command == "down" then
turtle.down()
elseif command == "place" then
turtle.place()
elseif command == "digup" then
turtle.digUp()
elseif command == "digdown" then
turtle.digDown()
elseif command == "placeup" then
turtle.placeUp()
elseif command == "placedown" then
turtle.placeDown()
end
function turtleforward()
if turtle.forward() then
positiony = positiony + 1
elseif turtle.back() then
positiony = positiony - 1
elseif turtle.up() then
positionz = positionz + 1
elseif turtle.down() then
positionz = positionz - 1
end
end
function turtleright()
if turtle.forward() then
positionx = positionx + 1
elseif turtle.back() then
positionx = positionx - 1
elseif turtle.up() then
positionz = positionz + 1
elseif turtle.down() then
positionz = positionz - 1
end
end
function turtleleft()
if turtle.forward() then
positionx = positionx - 1
elseif turtle.back() then
positionx = positionx + 1
elseif turtle.up() then
positionz = positionz + 1
elseif turtle.down() then
positionz = positionz - 1
end
end
function turtleback()
if turtle.forward() then
positiony = positiony - 1
elseif turtle.back() then
positiony = positiony + 1
elseif turtle.up() then
positionz = positionz + 1
elseif turtle.down() then
positionz = positionz - 1
end
end
local turn = turtleforward()
function orientacia()
if turn == turtlerovno() then
if turtle.turnLeft() then
turn = turtleleft()
elseif turtle.turnRight() then
turn = turtleright()
end
end
if turn == turtleleft() then
if turtle.turnLeft() then
turn = turtleback()
elseif turtle.turnRight() then
turn = turtlerovno()
end
end
if turn == turtleright() then
if turtle.turnLeft() then
turn = turtlerovno()
elseif turtle.turnRight() then
turn = turtleback()
end
end
if turn == turtleback() then
if turtle.turnLeft() then
turn = turtleright()
elseif turtle.turnRight() then
turn = turtleleft()
end
end
end
print (positionx..""..positiony..""..positionz)
orientacia()
end