Awkwardsaw
2009-07-03 05:25:07
im not sure if these are already in srl, but i made these functions out of sheer lazyness, and space saver
how i use it in my script:
:). this shaved off ~150 lines in this script so far, from taking away repeatedish functions.
and yes it does work, just would like to share it with you guys,
i know it has a hell of a lot of parameters, but long lines > 30 seconds and 21+ lines saved. although it would be nice to change this to xyz instead of hue
function FindObjHue(var a, b: integer; color: longint; x, y, cx1, cy1, cx2, cy2, tol: integer; hue, sat: extended; text: tstringarray): boolean;
var
CTS, I: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(hue, sat);
FindColorsSpiralTolerance(a, b, TPA, color, cx1, cy1, cx2, cy2, tol);
ColorToleranceSpeed(CTS);
ATPA := TPAToATPAEx(TPA, 15, 15);
For I := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], a, b);
MMouse(a, b, 2, 2);
wait(10 + random(30));
if IsUpTextMultiCustom(text) then
begin
Result := True;
GetMousePos(a, b);
Break;
end;
end;
end;
function FindColHue(var a, b: integer; color: longint; x, y, cx1, cy1, cx2, cy2, tol: integer; hue, sat: extended): boolean;
var
CTS, I: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(hue, sat);
FindColorsSpiralTolerance(x, y, TPA, color, cx1, cy1, cx2, cy2, tol);
ColorToleranceSpeed(CTS);
ATPA := TPAToATPAEx(TPA, 15, 15);
For I := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 2, 2);
Result := True;
GetMousePos(x, y);
Break;
end;
end;how i use it in my script:
procedure EnterPortal;
var x, y, a, b: integer;
portal: boolean;
begin
makecompass('N');
wait(2000 + random(1000));
portal:= FindObjHue(x, y, 8226691, MSCX, MSCY, MSX1, MSY1, MSX2, MSY2, 20, 1.66, 0.60, ['Enchanters', 'nchanters', 'chant']);
if not portal then
begin
messup('cannot find portal to leave');
exit;
end;
mouse(x, y, 0, 0, true);
while not findsymbol(a, b, 'Transportation') do wait(10 + random(30));
gotocenter;
end;:). this shaved off ~150 lines in this script so far, from taking away repeatedish functions.
and yes it does work, just would like to share it with you guys,
i know it has a hell of a lot of parameters, but long lines > 30 seconds and 21+ lines saved. although it would be nice to change this to xyz instead of hue