Posted 24 July 2012 - 04:15 PM
Hello everybody!
Im pretty new to coding and cc, so this might be nooby. Still, I whant to ask you guys what I could do about my reset program.
The first file called pumpkinfarm is a program to (you guessed it) farm pumpkins on 3 places. The turtle moves between three spaces and checks if there are pumkins in front of it and harvests them.
Easy. But since after rellogging in I would have to bring the turtles manually back into position I decided to write a program to reset them, so its called "reset".
Here comes the tricky bit. I let the turtle check its position by making it turn right until it detects with turtle.detect the fence behind it. Now we know which direction its facing.
I let it go right and forward until it detects a fence underneath it. This is the starting block. So I turn it toward the fence and let it turn left ( or right) 2 times. Now its successfully reseted.
The problem is that if the turtle stands on the starting block and faces the wrong direction, it goes totally wrong of course. Does anybody know how I could fix this?
pumkinfarm:
x = 1
while x == 1
do
local i = 1
repeat
if turtle.detect() == true
then turtle.dig()
turtle.turnLeft()
turtle.forward()
turtle.turnRight()
else turtle.turnLeft()
turtle.forward()
turtle.turnRight()
end
i = i + 1
until i == 3
local c = 1
repeat
if turtle.detect() == true
then turtle.dig()
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
else turtle.turnRight()
turtle.forward()
turtle.turnLeft()
end
c = c + 1
until c == 3
end
reset:
if turtle.compareDown() == true
then
while turtle.compare() == false
do turtle.turnRight()
end
turtle.turnLeft()
turtle.turnLeft()
end
while turtle.compare() == false
do turtle.turnRight()
end
turtle.turnLeft()
turtle.forward()
if turtle.compareDown() == false
then turtle.forward()
else while turtle.compare() == false
do turtle.turnRight()
end
end
turtle.turnLeft()
turtle.turnLeft()
http://
these are the turtles in reseted position. They both have a fence in their 1. slot for turtle.compare()
Im pretty new to coding and cc, so this might be nooby. Still, I whant to ask you guys what I could do about my reset program.
The first file called pumpkinfarm is a program to (you guessed it) farm pumpkins on 3 places. The turtle moves between three spaces and checks if there are pumkins in front of it and harvests them.
Easy. But since after rellogging in I would have to bring the turtles manually back into position I decided to write a program to reset them, so its called "reset".
Here comes the tricky bit. I let the turtle check its position by making it turn right until it detects with turtle.detect the fence behind it. Now we know which direction its facing.
I let it go right and forward until it detects a fence underneath it. This is the starting block. So I turn it toward the fence and let it turn left ( or right) 2 times. Now its successfully reseted.
The problem is that if the turtle stands on the starting block and faces the wrong direction, it goes totally wrong of course. Does anybody know how I could fix this?
pumkinfarm:
x = 1
while x == 1
do
local i = 1
repeat
if turtle.detect() == true
then turtle.dig()
turtle.turnLeft()
turtle.forward()
turtle.turnRight()
else turtle.turnLeft()
turtle.forward()
turtle.turnRight()
end
i = i + 1
until i == 3
local c = 1
repeat
if turtle.detect() == true
then turtle.dig()
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
else turtle.turnRight()
turtle.forward()
turtle.turnLeft()
end
c = c + 1
until c == 3
end
reset:
if turtle.compareDown() == true
then
while turtle.compare() == false
do turtle.turnRight()
end
turtle.turnLeft()
turtle.turnLeft()
end
while turtle.compare() == false
do turtle.turnRight()
end
turtle.turnLeft()
turtle.forward()
if turtle.compareDown() == false
then turtle.forward()
else while turtle.compare() == false
do turtle.turnRight()
end
end
turtle.turnLeft()
turtle.turnLeft()
http://
these are the turtles in reseted position. They both have a fence in their 1. slot for turtle.compare()