Jump to content




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


  • This topic is locked This topic is locked
10 replies to this topic

#1 anoliss

  • New Members
  • 4 posts

Posted 05 April 2012 - 05: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

#2 ComputerCraftFan11

  • Members
  • 771 posts
  • LocationHawaii

Posted 05 April 2012 - 05: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


#3 Liraal

  • New Members
  • 477 posts
  • LocationPoland

Posted 05 April 2012 - 06:19 AM

Well, I would say that too, except that it is painfully slow when it comes to pathfinding and stuff like that.

#4 anoliss

  • New Members
  • 4 posts

Posted 05 April 2012 - 01:48 PM

 ComputerCraftFan11, on 05 April 2012 - 05:29 AM, said:

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.

#5 Dirkus7

  • Members
  • 148 posts
  • Locationthe Netherlands

Posted 12 April 2012 - 07: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/>

#6 kamnxt

  • New Members
  • 80 posts

Posted 16 April 2012 - 06:52 PM

 Dirkus7, on 12 April 2012 - 07:33 PM, said:

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 :)/>)

#7 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

Posted 16 April 2012 - 08:33 PM

 ComputerCraftFan11, on 05 April 2012 - 05:29 AM, said:

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


#8 merpelicous

  • Members
  • 5 posts

Posted 20 May 2013 - 02:34 PM

 Dirkus7, on 12 April 2012 - 07:33 PM, said:

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.

#9 jesusthekiller

  • Banned
  • 562 posts
  • LocationWrocław, Poland

Posted 20 May 2013 - 04: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


#10 H4X0RZ

  • Members
  • 1,315 posts
  • LocationGermany

Posted 20 May 2013 - 05:59 PM

 jesusthekiller, on 20 May 2013 - 04:21 PM, said:

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.

#11 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 21 May 2013 - 01:50 PM

This was already denied. It won't be added. Don't bring up something from over a year ago.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users