SRL Archive - Help and Support

SCAR.exe Errors


Fizzi

2007-08-21 17:34:03

Well, I turned my clay farmer on, and wen't to work. 6 hours or so later (According to the proggy that was still on the screen). This error showed up in the debug box: [Runtime Error] : Exception: Out of memory in line 341 in script C:\Program Files\SCAR 3.11\Scripts\My Soft Clay Farmer 2.0.scar . On top of that I had a popup window saying that SCAR had encountered an unexpected error or whatever (Pressing Ok closed SCAR).

Here is the function which contains line 341 (The line itself has a comment next to it):
function FindMultiMovementColorTol(TStop, Frequency : Integer; ColorMoving : Integer;
x1, y1, x2, y2 : Integer; Tolerance : Integer; MCPixels : Integer) : boolean;
var
TSearch, PCount, CCount, MCCount, slength, sheight, i, k : Integer;
Movement : Boolean;
begin
slength := (x2 - x1);
sheight := (y2 - y1);
PCount := 0; CCount := 0;
for i := 0 to sheight do
begin
if (i = 0) or ((i mod 2) = 0) then
begin
for k := 0 to (slength/2) do
begin
setlength(Points, length(Points)+1); //This is line 341
Points[PCount].x := (x1 + (2*k));
Points[PCount].y := (y1 + i);
PCount := (PCount + 1);
end;
end else
begin
if((slength mod 2) = 0) then
begin
for k := 0 to ((slength/2) - 1) do
begin
setlength(Points, length(Points)+1);
Points[PCount].x := (x1 + 1 + (2*k));
Points[PCount].y := (y1 + i);
PCount := PCount + 1;
end;
end else
begin
for k := 0 to (slength/2) do
begin
setlength(Points, length(Points)+1);
Points[PCount].x := (x1 + 1 + (2*k));
Points[PCount].y := (y1 + i);
PCount := (PCount + 1);
end;
end;
end;
end;
MarkTime(TSearch);
repeat
for i := 0 to (PCount - 1) do
begin
setlength(Points[i].Color, length(Points[i].Color)+1);
Points[i].Color[CCount] := GetColor(Points[i].x, Points[i].y);
end;
CCount := CCount + 1;
Wait(Frequency);
until(TimeFromMark(TSearch) > TStop);
for i := 0 to (PCount - 1) do
begin
Movement := False;
for k := 0 to (CCount - 2) do
begin
if(Points[i].Color[k] <> Points[i].Color[k+1]) then Movement := True;
end;
if Movement then
begin
for k := 0 to (CCount - 1) do
begin
if(SimilarColors(Points[i].Color[k], ColorMoving, Tolerance)) then MCCount := MCCount + 1;
end;
end;
end;
if(MCCount >= MCPixels) then Result := True
else Result := False;
end;

That function above is called every time before the character clicks the rock, so it's called a lot. This error really upsets me because… It seems like the only thing that stops my scripts from making amazing runs now are SCAR errors (I get a SCAR error like every overnight run). It sucks, I still had 11 out of 12 players still running after 6 hours! So I'd like to know if anyone knows what the problem is, and if it's fixable. My laptop however, seems completely immune to this problem…

Starblaster100

2007-08-21 17:35:56

You are constantly loading bitmaps or dtms into the memory without freeing them. You just have to load them once in the script, make sure that the loading procedure is not in a loop

LordGregGreg

2007-08-21 17:41:03

hmm, well first off, great job on getting the script to run so flawlessly, that is very impressive :D

Second, i have not recived that error before… but i have some gueses on how to fix it.

Perhaps the script does not release or free the bitmaps it is loading up? That is my best guesee, loko and make sure it freezes the bit map after it is done using it.

Other than that.. posibly redownload scar.

Fizzi

2007-08-21 17:46:34

From: Starblaster100
You are constantly loading bitmaps or dtms into the memory without freeing them. You just have to load them once in the script, make sure that the loading procedure is not in a loop

In my most recent version, I moved all my item DTMs to one load procedure. My fork DDTM's, however, are loaded and freed every time the script walks. So maybe that's it, I'll try changing it and post here how it goes. Thank you for the speedy response :).

From: lordgreggreg
hmm, well first off, great job on getting the script to run so flawlessly, that is very impressive :D

Second, i have not recived that error before… but i have some gueses on how to fix it.

Perhaps the script does not release or free the bitmaps it is loading up? That is my best guesee, loko and make sure it freezes the bit map after it is done using it.

Other than that.. posibly redownload scar.

I'm fairly certain that I free everything I load, except for the DTM's which apparently i shouldn't be constantly uploading/freeing. Thanks for the suggestion though =D.

Bobarkinator

2007-08-21 20:21:43

Just put all your DTM's in a LoadDTM procedure and call it at the beginning of the script and that's all. Never call it again. Put the walking DTM's in with it also.

Edit: Wooters, I got scripting cup.

Fizzi

2007-08-22 15:23:50

Well, I attempted to modify my script by moving my two fork DDTM's into my LoadDTMs procedure called at the begining of the script. The problem was… even though I had set the color of the subpoints and mainpoint to MMRoadCol which is updated frequently in my loops, the color of the DDTM was not changed… A DDTM is supposed to change when you change the variable that you assign SP[0].Color := to right? It doesn't seem to be working.

LordGregGreg

2007-08-22 16:45:31

From: Fizzi
Well, I attempted to modify my script by moving my two fork DDTM's into my LoadDTMs procedure called at the begining of the script. The problem was… even though I had set the color of the subpoints and mainpoint to MMRoadCol which is updated frequently in my loops, the color of the DDTM was not changed… A DDTM is supposed to change when you change the variable that you assign SP[0].Color := to right? It doesn't seem to be working.


SP[0].Color := needs to be set to the varible that changes. you cannot have it set to a regual integer color , else it wil never change.
so
SP[0].Color := RoadColor; is what you want.

you should loaddtm right ebfore you are about to use it, to make sure you have the most updated colors in that dtm.

if you really want, you could do
SP[0].Color := FindRoadColor
right before you want to search for it.

Santa_Clause

2007-08-24 05:42:39

DDTM nerds…they never work for me :p

ZephyrsFury

2007-08-24 05:53:53

From: SantaClause
DDTM nerds…they never work for me :p


Forms nerd… DDTM's are much more useful…. :D Read a tutorial… YoHoJo's is good: http://www.villavu.com/forum/showthread.php?t=12584
So is Fawki's which I can't seem to find the URL of….

EDIT: Oh heres Fawki's Tut: http://www.villavu.com/forum/showthread.php?t=10008

Santa_Clause

2007-08-24 05:58:00

I've read it and all…it just never finds it :p

ZephyrsFury

2007-08-24 06:02:04

Lol mine always works :p… I'll help you with DDTM's if you need it.

Santa_Clause

2007-08-24 07:55:21

I might bother one day…:p