Fizzi
2007-07-09 15:40:39
I'm trying to use this in my script and it's failing often. Maybe it's just me?
Wondering if anyone else is having this problem.
Wondering if anyone else is having this problem.
2007-07-09 15:40:39
2007-07-09 15:43:01
2007-07-09 15:45:06
2007-07-09 15:48:20
function SumFindRoadColor(FalaColor: Boolean): Integer;
var
arRoadPoints: TPointArray;
GenericColor, a, b: Integer;
arRoughRoadColors, arRoadColors: array of Integer;
WeGotIt: Boolean;
ResultString: string;
begin
if(FalaColor)then
GenericColor := 6057843
else
GenericColor := 5921377;
if(FalaColor)then
ResultString := 'Fala';
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(10.0, 0.03);
FindColorsTolerance(arRoadPoints, GenericColor, MMX1, MMY1, MMX2, MMY2, 50);
ColorToleranceSpeed(1);
arRoughRoadColors := GetColors(arRoadPoints);
for a := 0 to GetArrayLength(arRoughRoadColors) - 1 do
begin
WeGotIt := False;
if(arRoughRoadColors[a] > 5000000)and(arRoughRoadColors[a] < 8000000)then
begin
for b := 0 to GetArrayLength(arRoadColors) - 1 do
begin
if(arRoadColors[b] = arRoughRoadColors[a])then
WeGotIt := True;
end;
if not(WeGotIt)then
begin
if(CountColor(arRoughRoadColors[a], MMX1, MMY1, MMX2, MMY2) > 200)then
begin
if(rs_OnMinimap(arRoadPoints[a].x, arRoadPoints[a].y))then
begin
//Writeln(IntToStr(arRoughRoadColors[a]));
SetArrayLength(arRoadColors, GetArrayLength(arRoadColors) + 1);
arRoadColors[GetArrayLength(arRoadColors) - 1] := arRoughRoadColors[a];
end;
end;
end;
end;
end;
if not(GetArrayLength(arRoadColors) = 1)then
begin
Writeln('Failed to find the road using SumFindRoadColor.');
Writeln('Trying default autocoloring.');
if(FalaColor)then
Result := FindFallyRoadColor
else
Result := FindRoadColor;
end else
Result := arRoadColors[0];
Writeln('RoadColor = '+IntToStr(Result));
if(Result = 0)then
begin
Writeln('Failed to find the road color.');
Writeln('Leaving it what it was.');
if(FalaColor)then
Result := FalaRoadColor
else
Result := RoadColor;
end;
end;
2007-07-09 16:07:31
2007-07-09 16:09:39
2007-07-09 16:18:36
2007-07-09 16:19:59
From: tarajunky
There is a new function in Divi that checks if a point is on the minimap that could be used to solve this as well, but I need to find out how to use it first. :)
for a:= 0 to l-1 do
if rs_OnMiniMap(P[a].x, P[a].y) then
begin
TestColor := GetColor(P[a].x, P[a].y);
2007-07-09 16:24:19
x:=MMCX;
y:=MMCY;
FindColorsSpiralTolerance(x, y, P, GC, MMX1, MMY1, MMX2, MMY2, 50); FindColorsSpiralTolerance(MMCX, MMCY, P, GC, MMX1, MMY1, MMX2, MMY2, 50);2007-07-09 16:42:30
2007-07-09 16:46:56
From: tarajunky
Thanks to everyone for the help. :) I updated all my Autocolor functions to search from the center of the minimap and to use rs_OnMiniMap. This should fix FindFallyRoadColor completely, and will be an added failsafe for the others.
I'll remove my earlier attached file, and if everyone else could remove their attached files as well, we can hopefully reduce any confusion. Thanks!
I'll post this on the SRL 3.81 download section as well.
2007-07-09 16:50:07
2007-07-09 16:57:21
From: 3garrett3
Thanks tara, do you know if FindDirtRoadColor works anymore? I tested it with 3.6, and it didnt. I was thinking of updating my script though, but I cant get any other autocolor methods to work for it either.
2007-07-09 17:36:47
2007-07-09 17:55:06
From: 3garrett3
Thanks tara, do you know if FindDirtRoadColor works anymore? I tested it with 3.6, and it didnt. I was thinking of updating my script though, but I cant get any other autocolor methods to work for it either.
2007-07-10 01:45:18
program New;
{.include srl/srl.scar}
procedure XYZtoLab(X, Y, Z : Extended; var L, A, B : Extended);
begin
try
L := 10 * Sqrt(Y);
A := 17.5 * (((1.02 * x)-y) / Sqrt(Y));
B := 7 * ((Y-(0.847 * Z)) / Sqrt(Y));
except
end;
end;
procedure LabToXYZ(L, A, B : Extended; var X, Y, Z : Extended);
begin
try
Y := Pow(L / 10, 2);
X := ((A / 17.5 * L / 10) + Y) / 1.02;
Z := -((B / 7 * L / 10) - Y) / 0.847;
except
end;
end;
procedure ColorToLab(color :integer; var L, A, B : Extended);
var
X,Y,Z: Extended;
begin
ColortoXYZ(color, X, Y, Z);
XYZtoLab(X, Y, Z, L, A, B);
end;
function AMin(Data : TIntegerArray) : integer;
var
i : integer;
begin
if (GetArrayLength(Data) = 0) then exit;
Result := Data[0];
for i:= 1 to GetArrayLength(Data)-1 do
if (Data[i] < Result) then
Result := Data[i];
end;
function AMostColor(DataColor : TIntegerArray; x1, y1, x2, y2 : Integer) : Integer;
var
i, most, index, L, count: integer;
begin
L := GetArrayLength(DataColor);
if (L = 0) then Exit;
Most := CountColor(DataColor[0], x1, y1, x2, y2);
for i := 0 to L-1 do
begin
Count := CountColor(DataColor[i], x1, y1, x2, y2);
if (Count > Most) then
begin
Index := i;
Most := Count;
end;
end;
Result := DataColor[index];
end;
procedure RGBToHSV(R, G, B : Integer; var H, S, V : Extended);
var
Delta, MaxRGB, MinRGB : Extended;
begin
try
MaxRGB := AMax([R, G, B]);
MinRGB := AMin([R, G, B]);
Delta := (MaxRGB - MinRGB);
V := MaxRGB;
H := -1.0;
if (MaxRGB <> 0) then S := 255 * Delta / MaxRGB;
if (S <> 0) then
if (R = Trunc(MaxRGB)) then H := (G - B) / Delta else
if (G = Trunc(MaxRGB)) then H := 2 + (B - R) / Delta else
if (B = Trunc(MaxRGB)) then H := 4 + (r - g) / Delta;
H := H * 60;
if ( H < 0) then H := H + 360;
S := S * 100 / 255;
V := V * 100 / 255;
except
Writeln('[RunTime ERROR] : Found Math ERROR');
end;
end;
procedure ColorToHSV(Color : Integer; var H, S, V : Extended);
var
R, G, B : Integer;
begin
ColortoRGB(Color, R, G, B);
RGBToHSV(R, G, B, H, S, V);
end;
function GetFallyRoadColor : Integer;
var
P : TPointArray;
Data : TIntegerArray;
Color, i : integer;
L, A, B, H, S, V : Extended;
begin
if (not(LoggedIn)) then exit;
Flag;
Color := 6187637;
x := MMCX;
y := MMCY;
FindColorsSpiralTolerance(x, y, P, Color, MMX1, MMY1, MMX2, MMY2, 50);
Data := GetColors(P);
for i := 0 to GetArrayLength(Data)-1 do
begin
if (rs_OnMinimap(P[i].x, P[i].y)) then
begin
ColorToHSV(Data[i], H, S, V);
ColorToLab(Data[i], L, A, B);
if (V > 30) and (V < 60) then
if (S > 15) and (S < 35) then
if (H > 30) and (H < 60) then
if (CountColor(Data[i], MMX1, MMY1, MMX2, MMY2) > 100) then
if (B < 0.0) and (B > -10.0) and (A < 30) then
begin
Color := Data[i];
Result := Color;
Writeln('Fally RoadColor = ' + inttostr(Result));
MMouse(P[i].x, P[i].y, 0, 0);
Exit;
end;
end;
end;
Result := AMostColor(Data, MMX1, MMY1, MMX2, MMY2);
if (CountColor(Result, MMX1, MMY1, MMX2, MMY2) < 300) then
Result := 0;
end;
begin
SetUpSrl;
FindRS;
ActivateClient;
Wait(1000);
GetFallyRoadColor;
end.
2007-07-10 03:06:04
From: Sumilion
Or try my function :) (*cough* does require you to login + out once!!! *coug*)function SumFindRoadColor(FalaColor: Boolean): Integer;
var
arRoadPoints: TPointArray;
GenericColor, a, b: Integer;
arRoughRoadColors, arRoadColors: array of Integer;
WeGotIt: Boolean;
ResultString: string;
begin
if(FalaColor)then
GenericColor := 6057843
else
GenericColor := 5921377;
if(FalaColor)then
ResultString := 'Fala';
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(10.0, 0.03);
FindColorsTolerance(arRoadPoints, GenericColor, MMX1, MMY1, MMX2, MMY2, 50);
ColorToleranceSpeed(1);
arRoughRoadColors := GetColors(arRoadPoints);
for a := 0 to GetArrayLength(arRoughRoadColors) - 1 do
begin
WeGotIt := False;
if(arRoughRoadColors[a] > 5000000)and(arRoughRoadColors[a] < 8000000)then
begin
for b := 0 to GetArrayLength(arRoadColors) - 1 do
begin
if(arRoadColors[b] = arRoughRoadColors[a])then
WeGotIt := True;
end;
if not(WeGotIt)then
begin
if(CountColor(arRoughRoadColors[a], MMX1, MMY1, MMX2, MMY2) > 200)then
begin
if(rs_OnMinimap(arRoadPoints[a].x, arRoadPoints[a].y))then
begin
//Writeln(IntToStr(arRoughRoadColors[a]));
SetArrayLength(arRoadColors, GetArrayLength(arRoadColors) + 1);
arRoadColors[GetArrayLength(arRoadColors) - 1] := arRoughRoadColors[a];
end;
end;
end;
end;
end;
if not(GetArrayLength(arRoadColors) = 1)then
begin
Writeln('Failed to find the road using SumFindRoadColor.');
Writeln('Trying default autocoloring.');
if(FalaColor)then
Result := FindFallyRoadColor
else
Result := FindRoadColor;
end else
Result := arRoadColors[0];
Writeln('RoadColor = '+IntToStr(Result));
if(Result = 0)then
begin
Writeln('Failed to find the road color.');
Writeln('Leaving it what it was.');
if(FalaColor)then
Result := FalaRoadColor
else
Result := RoadColor;
end;
end;
2007-07-10 04:58:54
From: Wizzup?
Familiar code…. ;)
2007-07-10 13:19:35
2007-07-10 13:28:09
From: tarajunky
He must use your Rimmington miner a lot?? :D