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

Turtles, turtle.detectLeft() turtle.detectRight()

Started by anoliss, 05 April 2012 - 04:19 AM
anoliss #1
Posted 05 April 2012 - 06:19 AM
I think that turtles should be able to detect objects on either side to aid in navigation.
Great work so far, I'm excited to see what's ahead!

–Anoliss
ComputerCraftFan11 #2
Posted 05 April 2012 - 06:29 AM
Can't you just do this?
 
function detectLeft()
   turtle.turnLeft()
   return(turtle.detect())
   turtle.turnRight()
end
function detectRight()
   turtle.turnRight()
   return(turtle.detect())
   turtle.turnLeft()
end
Liraal #3
Posted 05 April 2012 - 07:19 AM
Well, I would say that too, except that it is painfully slow when it comes to pathfinding and stuff like that.
anoliss #4
Posted 05 April 2012 - 02:48 PM
Can't you just do this?

function detectLeft()
   turtle.turnLeft()
   return(turtle.detect())
   turtle.turnRight()
end
function detectRight()
   turtle.turnRight()
   return(turtle.detect())
   turtle.turnLeft()
end

You, could. However, I agree with Liraal, it would be more efficient to have detectors for the sides.
Dirkus7 #5
Posted 12 April 2012 - 08:33 PM
True, but humans don't have eyes on the sides of their head.
But you're right, robots can have them, so why not turtles? They should have them.
And if left and right detecing is added, why not add turtle.detectBack() too? :P/>/>
kamnxt #6
Posted 16 April 2012 - 07:52 PM
True, but humans don't have eyes on the sides of their head.
But you're right, robots can have them, so why not turtles? They should have them.
And if left and right detecing is added, why not add turtle.detectBack() too? :)/>/>
Humans don't have eyes on the sides of their head, but they have hands (not on their head :)/>/>)
Cloudy #7
Posted 16 April 2012 - 09:33 PM
Can't you just do this?

function detectLeft()
   turtle.turnLeft()
   return(turtle.detect())
   turtle.turnRight()
end
function detectRight()
   turtle.turnRight()
   return(turtle.detect())
   turtle.turnLeft()
end

Just to point out, that function wouldn't work as it will return from the function before it turns back. A better solution would be this:
function detectLeft()
   turtle.turnLeft()
   local ret = turtle.detect()
   turtle.turnRight()
   return ret
end
function detectRight()
   turtle.turnRight()
   local ret = turtle.detect()
   turtle.turnLeft()
   return ret
end
merpelicous #8
Posted 20 May 2013 - 03:34 PM
True, but humans don't have eyes on the sides of their head.
But you're right, robots can have them, so why not turtles? They should have them.
And if left and right detecing is added, why not add turtle.detectBack() too? :P/>/>
But we can move our eyes from side to side.
jesusthekiller #9
Posted 20 May 2013 - 05:21 PM
But we can't see our a*s.

Do something like:

function detect(side)
  rs.setOutput(side, true)
  local r = rs.getInput(side)
  rs.setOutput(side, false)
  return r
end
H4X0RZ #10
Posted 20 May 2013 - 06:59 PM
But we can't see our a*s.

Do something like:

function detect(side)
  rs.setOutput(side, true)
  local r = rs.getInput(side)
  rs.setOutput(side, false)
  return r
end
That only works with solid blocks, but not with trap doors etc.
Cranium #11
Posted 21 May 2013 - 02:50 PM
This was already denied. It won't be added. Don't bring up something from over a year ago.