bud_wis_er_420
2013-04-05 23:12:56
I made this function to get my hp lvl. Yes I know there is a SRL function for that but I want mine to work in all resolutions. The part in my function that keeps failing it the FindColors function. It is not finding the txt colors when I know they are there. For god sakes it is a constant color. It don't change. But it won't even find the color with a tol of 30. I even have a sort of debug in my function to make sure the box it is looking for the colors in, is correct.
This is so frustrating. I been going back and forth with this for hours now. Please someone tell me whats going on.
This is so frustrating. I been going back and forth with this for hours now. Please someone tell me whats going on.
function GetHealth: Integer;
var
i, W, H: Integer;
Box, TempBox: TBox;
Colors : TIntegerArray;
TPA: TPointArray;
txt: string;
begin;
Result := -1;
GetClientDimensions(W, H);
if FixedScreen then
Box := IntToBox(719,27,745,43)
else Box := IntToBox(W - 223, 46, w - 183, 66);
//check box cords
MMouse(Box.X1, Box.Y1,0,0);
wait(2000);
MMouse(Box.X2, Box.Y2,0,0);
wait(2000);
//Loops through all 4 Health colors
Colors := [65280, 65535, 2070783, 255];
for i := 0 to 3 do
begin
writeln('Color looking for is: ' + IntToStr(Colors[i]));
if FindColorsTolerance(TPA, Colors[i], Box.X1, Box.Y1, Box.X2, Box.Y2, 30) then
begin
TempBox := GetTPABounds(TPA);
//check box cords
MMouse(TempBox.X1, TempBox.Y1,0,0);
wait(2000);
MMouse(TempBox.X2, TempBox.Y2,0,0);
//check text before number
txt := GetTextAtExWrap(TempBox.X1, TempBox.Y1, TempBox.X2, TempBox.Y2, 0, 4, 4, Colors[i], 0, statChars);
writeln(txt);
Result := StrToIntDef(GetNumbers(GetTextAtExWrap(TempBox.X1, TempBox.Y1, TempBox.X2, TempBox.Y2, 0, 4, 4, Colors[i], 0, statChars)), -1);
if (Result > -1) then
Exit;
end else writeln('The Color was not found: ' + IntToStr(Colors[i]));
end;
end;