SRL Archive - SRL Bugs

AutoColor issues.


noidea

2011-06-06 21:35:16

Im trying to use AutoColor(srl_TreeColor) and I occationally run into an error

colortree := AutoColor(srl_TreeColor);

results in Math error at line 239 in color.scar, function GetColorArrayInfo.

the line is

Result[ii][2] := Result[ii][2] / h;

jerryt

2011-06-06 22:18:21

I can't seem to produce the same error you are having. Could you possibly post the script or send it to me through e-mail?

BraK

2011-06-06 22:32:01

You have the Script :)

//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- AutoColorFinding Routines --//
//-----------------------------------------------------------------//
// * procedure SetupAutoColors;
// * function LoadColorArray(Which: Integer): TIntegerArray;
// * function LoadAutoColor(which: Integer; var theAC: TAutoColorInfo): Boolean;
// * function AutoColorEx(which: Integer): TAutoColorInfo;
// * function AutoColor(which: Integer): Integer;
//-----------------------------------------------------------------//

{ const AutoColor Constants;
Description: Constants representing the different types of AutoColors }
const
srl_AutoColorCount = 13;
srl_VarrockRoadColor = 0;
srl_LumbridgeRoadColor = 1;
srl_FaladorRoadColor = 2;
srl_AlKharidRoadColor = 3;
srl_DarkDirtRoadColor = 4;
srl_LightDirtRoadColor = 5;
srl_SandColor = 6;
srl_WaterColor = 7;
srl_SwampWaterColor = 8;
srl_LadderColor = 9;
srl_RockColor = 10;
srl_MineRockColor = 11;
srl_TreeColor = 12;


~BraK

jerryt

2011-06-06 22:34:58

No, Brak.

I need to take a look at his script to see what is causing the problem.

noidea

2011-06-06 22:37:12

function gettrees(var ptr: TPoint): boolean;
var
tpatree, tpatreebest: TPointArray;
atpatree: array of TPointArray;
i, colortree: Integer;
ptree: TPoint;
begin
result := false;
if not LoggedIn then exit;
ptr := point(-1, -1);
colortree := AutoColor(srl_TreeColor);
findColorsTolerance(tpatree, colortree, mmx1, mmy1, mmx2, mmy2, 15);
DebugTPA(tpatree, 'a');
wait(2000);
if high(tpatree) = 0 then writeln('nope');
FilterPointsPie(tpatree, 180, 265, 10, 70, mmcx, mmcy);
DebugTPA(tpatree, 'mmtrees');
atpatree := SplitTPA(tpatree, 15);
for i := 0 to high(atpatree) do
if high(atpatree[i]) > high(tpatreebest) then
tpatreebest := atpatree[i];
DebugTPA(tpatreebest, 'tpatree');
if length(tpatreebest) < 1 then
exit;
writeln('a')
ptr := MiddleTPA(tpatreebest)
result := true;
end;

I just tried the function with colour 0 instead of AutoColoring, and I didnt get the error, but Im standing in draynor bank. Tried it with AutuColor and it did it again.

jerryt

2011-06-06 22:42:43

Could you send me the full script to examine? I am still not getting any error.

Is this a script you wrote, or did someone else write this?

noidea

2011-06-06 23:32:15

edit: nvm its working now o_O, maybe my shits just going crazy.

I'd rather not, but if I dont work it out Ill post it here. Im just reworking an old script and thats the only new procedure.

If anyones having this same error, http://villavu.com/forum/showpost.php?p=613151&postcount=16 FindTreeColor still works (haha after 2 years :rolleyes:)

Nava2

2011-06-07 08:54:14

"Math Errors" are typically when you divide by the wrong type or zero.. but divide by zero is said as such.. I'm wondering if it was NaN or something similar? Perhaps I did not initialize the variables correctly.