can a variable hold many colorid

Ask gaming related questions (AHK v1.1 and older)
jojo95752003
Posts: 8
Joined: 13 Feb 2018, 23:10
Contact:

can a variable hold many colorid

22 Feb 2018, 02:34

hello! i have been working on a script that helps me to detect HP in a game.

F9::
Loop
{
pixelsearch, px, py, 199, 47, 211, 62, 0x0008CC, 3, fast
if errorlevel
pixelsearch, px, py, 199, 47, 211, 62, 0x0008C8, 3, fast
if errorlevel
pixelsearch, px, py, 199, 47, 211, 62, 0x0008C9, 3, fast
if errorlevel
pixelsearch, px, py, 199, 47, 211, 62, 0x0008C8, 3, fast
if errorlevel
pixelsearch, px, py, 199, 47, 211, 62, 0x0008D3, 3, fast
if errorlevel
mouseclick, left, 513, 608
; msgbox, that color was not found
else
; mouseclick, left, 509, 619
mousemove, %px%, %py%
sleep, 3000
}
return


as you can see, there are many colorid in my script, and there are more.. if i put all of the them into my script, it would be a mess.
my question is .. can i put all those colorid into only one variable? something like

F9::
colorid = "0x0008CC" "0x0008C8" "0x0008C9" "0x0008C8" "0x0008D3"

Loop
{
pixelsearch, px, py, 199, 47, 211, 62, %colorid%, 3, fast
if errorleve
mouseclick, left, 513, 608
; msgbox, that color was not found
else
; mouseclick, left, 509, 619
mousemove, %px%, %py%
sleep, 3000
}
return


so that i can make it easier to read?

thank you so much for reading my question:))
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: can a variable hold many colorid

22 Feb 2018, 03:03

Code: Select all

cIndex := ["0x0008CC","0x0008C8","0x0008C9","0x0008C8","0x0008D3"]

Loop % cIndex.Length() {
   MsgBox % cIndex[A_Index]
   PixelSearch, px, py, 199, 47, 211, 62, cIndex[A_Index], 3, fast
   Random, px, 0, A_ScreenWidth   ; only for testing
   Random, py, 0, A_ScreenHeight   ; only for testing
   ClipBoard .= px . ":" . py . "|"
   }
MsgBox % SubStr(ClipBoard,1,-1) 
Not tested.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 44 guests