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

Fill program (measures a space and fills it in)

Started by lIlIlIIlll, 27 September 2012 - 11:14 PM
lIlIlIIlll #1
Posted 28 September 2012 - 01:14 AM
I have the program done, the issue that I am having is getting the turtle oriented before it starts measuring…

I want to make it foolproof so that no matter what corner you put it in, facing the wall, not facing the wall, it will turn until it is in the correct position and start measuring the room (clockwise)

The turtle should be facing forward, with the wall on its left.

I have been trying this:


function whereami()
while turtle.notdetect()
do
??
end
while turtle.detect()
do
turtle.turnLeft()
end

whereami()

Let me illustrate:




NIN3 #2
Posted 28 September 2012 - 02:29 AM
I have the program done, the issue that I am having is getting the turtle oriented before it starts measuring…

I want to make it foolproof so that no matter what corner you put it in, facing the wall, not facing the wall, it will turn until it is in the correct position and start measuring the room (clockwise)

The turtle should be facing forward, with the wall on its left.

I have been trying this:


function whereami()
while turtle.notdetect()
do
??
end
while turtle.detect()
do
turtle.turnLeft()
end

whereami()

Let me illustrate:

-insert pictures NIN3 cant see-

Ok, so assuming that your turtle is in the middle of a perfectly square room, why not just make sure its in the corner? oh well…

terriblevari = 1
function findCorner()
turtle.turnLeft()
while terriblevari==2 do
wallfound2 = turtle.detect()
if wallfound2 == true then do
terriblevari = 3
turtle.turnLeft()
else
turtle.forward()
end  --Im not sure if this is enough ends, you would have to check to make sure....
function findWall()
while terriblevari==1 do
wallfound = turtle.detect()
if wallfound == true then do
terriblevari = 2
findCorner()
else
turtle.forward()
end		--The inverse is true to, this could be to many....
end

I hope this is right, Im not on a computer with computercraft on it atm…
Edited on 28 September 2012 - 12:31 AM
jag #3
Posted 28 September 2012 - 06:24 AM
turtle.notdetect()
What's that?
turtle.notdetect()
I think you mean
not turtle.detect()

EDIT: BTW you'r images dosen't work