SRL Archive - First Scripts

nest colours (Click here)


xtrapsp

2012-02-23 14:51:04

so your struggling with nests because the colours are so god damn annoying!
I've taken the time to get multiple angles for you and take all the colours as well as provide the code for mainscreen use :)

Pictures attached


AutoColor Function Code:
program AutoColor;
{.include SRL\SRL.scar}

function AutoColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.39, 0.74);

if not (FindColorsTolerance(arP, 2964028, MSX1, MSY1, MSX2, MSY2, 10)) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;

begin
SetupSRL;
AutoColor;
end.

FindObject Function code:
program FindObject;
{.include SRL\SRL.scar}

var
x, y: Integer;

function FindObject(var fx, fy: Integer): Boolean;
var
arP: TPointArray;
ararP: T2DPointArray;
tmpCTS, i, arL: Integer;
P: TPoint;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.39, 0.74);

if not(FindColorsTolerance(arP, 2964028, MSX1, MSY1, MSX2, MSY2, 10)) then
begin
Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

SortTPAFrom(arP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arP, 10, 10);
arL := High(ararP);

for i := 0 to arL do
begin
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
Wait(100 + Random(100));
if (IsUpText('Take')) then
begin;
Result := True;
Break;
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
begin
Writeln('FindObject could not find object.');
Exit;
end;

GetMousePos(fx, fy);
end;

begin
SetupSRL;
FindObject(x, y);
end.

Tutorial:
http://www.youtube.com/watch?v=98wVrr6GwyU&feature=plcp&context=C39b94a1UDOEgsToPDskIUAIuiT0poDPyfpZIXtfWO

Note:
Yes part of that dead tree is selected. But it's not near Ivy's :)