Help - Search - Members - Calendar
Full Version: If/else color checking
AC Tools Everything Macro > AC Tool Macros > Macro Development
mimicStrategy
I've got a rather challenging situation (since I'm new at macros). In a racing game, at the beginning theres a countdown that varies by a fraction of a second, most likely to to prevent macroing. Is there anyway I could have it check for a specific color (specified by the color's HEX value), if returned true have it recheck (every few milliseconds), and if returned false have it continue the script?

Really, I'm looking for something like this (not sure how to write it yet, I'm learning)

CODE
Loop 5000
If pixel123,123 = #D2B48C
Delay 5
End
Else
(yadda yadda my script goes here)


Also, is there another way I can loop it back without otherwise leaving the loop open?
DaMOB
QUOTE(mimicStrategy @ Jul 23 2009, 04:12 AM) *
I've got a rather challenging situation (since I'm new at macros). In a racing game, at the beginning theres a countdown that varies by a fraction of a second, most likely to to prevent macroing. Is there anyway I could have it check for a specific color (specified by the color's HEX value), if returned true have it recheck (every few milliseconds), and if returned false have it continue the script?

Really, I'm looking for something like this (not sure how to write it yet, I'm learning)

CODE
Loop 5000
If pixel123,123 = #D2B48C
Delay 5
End
Else
(yadda yadda my script goes here)


Also, is there another way I can loop it back without otherwise leaving the loop open?

To answer your question yes you can do this in ACTool. Now as far as that loop goes I would not do a loop but instead do it in a procedure with an infinite loop and break out of the loop on a false condition like so:
CODE
constants
  RValue = 0
  GValue = 0
  BValue = 0
  found = 0
end


Procedure lookforcolor using CoordX, CoordY
  while 1=1
    Call SetRGB $CoordX, $CoordY
    //use ranges for the colors as an equal may not always work
    if $RValue >207 and $RValue <213
      if $GValue >176 and $GValue <182
        if $BValue >137 and $BValue <143
          setconst found = 1
        end
      end
    end
    if found = 1
      delay 5
      setconst found = 0
    else
      break
    end
  end
End
Procedure SetRGB using CoordX, CoordY
  //Sets the RGB values from a particular location on the screen
  LoadRGB $CoordX, $CoordY
  SetConst RValue = {RGBRED}
  SetConst GValue = {RGBGREEN}
  SetConst BValue = {RGBBLUE}
End

Call lookforcolor 123,123
//continue the script from here because if we make it to here the procedure did not find the color
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.