# File AGTPixelColorValidator.rb, line 28 def wait_for_color (x,y,r,g,b,wait_for=10) pause_between_looks = 0.25 time_waited = 0 t_start = Time.new #puts "DEBUG: looking at pixel #{x}, #{y}" while true # leave this method when the color is found c = @robot.getPixelColor(x,y) # # KLUDGE: Have a "tolerance" here because colors aren't matching for # some reason. # #puts "DEBUG: color: #{c.getRed}, #{c.getGreen}, #{c.getBlue}" #return true if (r==c.getRed && g==c.getGreen && b==c.getBlue) return true if color_is_seen(c,r,g,b) # slight pause before looking for color again sleep pause_between_looks time_waited = Time.new - t_start # leave this method when we've waited as long as specified return false if time_waited > wait_for end end