SRL Archive - OSR Help

Expected Semicolon


void_hatred

2010-02-13 06:18:21

hey guys, I've been reading some tutorials during today and yesterday and have encountered a problem.

so using the documentation and some excellent tutorials, I tried making something out of what I had learned.


program RadialWalk;
{.include SRL/SRL.scar}

var
road_color: TIntegerArray; // is this two dimensional array of intgers? Array of Array of Integer?
i, j: Integer;

procedure init_variables;
begin
SetupSRL;

road_color := [
[8692140, 8823978, 8692135, 9021614, 8889771]
];
end;

begin
init_variables;

for i := 0 to High(road_color) do
begin
for j := 0 to High(road_color[i]) do
begin
if RadialRoadWalk(road_color[i][j], 60, 120, 72, 2, 2) then // expected Semicolon here
begin
WriteLn('Found: ' + IntToStr(road_color[i][j]));
break;
end else
begin
WriteLn('Could not find: ' + IntToStr(road_color[i][j]));
end;
FFlag(0);
end;
end;
end.

I get an error saying that there should be a semicolon on line 24, (oh and by the way, the reason why I use a two dimensional array for the colors is that I learned that they are dynamic, they keep changing, thus if I used one, it wouldn't work on the second test or something? oh and I tried FindLumbyRoadColor, but that didn't work, (I'm at lumby castle, outside))

oh and I will apologize in advance for my code, it is probably sloppy and needs standardization.

void_hatred

Gu3st...

2010-02-13 06:27:31

TIntegerArray = array of Integer
T2DIntegerArray = array of TIntegerArray / array of array of Integer

so changing road_color: TIntegerArray; to road_color: T2DIntegerArray; will fix the problem :)

void_hatred

2010-02-13 06:31:08

thanks for the reply, but I get another error.

this is apparently a type mismatch (though it's a 2D array, no?)


road_color := [
[8692140, 8823978, 8692135, 9021614, 8889771]
];

thanks in advance.

void_hatred

Quickmarch

2010-02-13 06:40:06

You are defining it as a T2DIntegerArray (Two arrays). You only need to wrap the colours in one []. ;)

void_hatred

2010-02-13 06:42:48

I've defined it as a two dimensional array for a specific purpose, eventually I will do..:

road_color := [
[…..],
[…..]
];

thus I do need the two pairs (outer and enclosing each individual color) of brackets, no?

void_hatred

Gu3st...

2010-02-13 06:49:58

From: Quickmarch
You are defining it as a T2DIntegerArray (Two arrays). You only need to wrap the colours in one []. ;)
If you take a look at the rest of the script then you see that he want's T2DIntegerArray, but he defined it as TIntegerArray

void_hatred

2010-02-13 07:14:40

Zyt3x, as I mentioned in a previous post I got another error (after making TIntegerArray into T2DIntegerArray) a type mismatch, any idea?

thanks for the help.

void_hatred

Frement

2010-02-13 07:19:18

Paste the whole code, it compiles just fine for me.

void_hatred

2010-02-13 07:27:02


program RadialWalk;
{.include SRL/SRL.scar}

var
road_color: T2DIntegerArray;
i, j: Integer;

procedure init_variables;
begin
SetupSRL;

road_color := [
[8692140, 8823978, 8692135, 9021614, 8889771]
];
end;

begin
init_variables;

for i := 0 to High(road_color) do
begin
for j := 0 to High(road_color[i]) do
begin
if RadialRoadWalk(road_color[i][j], 60, 120, 72, 2, 2) then
begin
WriteLn('Found: ' + IntToStr(road_color[i][j]));
break;
end else
begin
WriteLn('Could not find: ' + IntToStr(road_color[i][j]));
end;
FFlag(0);
end;
end;
end.

and yes, it compiles correctly, but try running it (then it gives mismatch)

void_hatred

Gu3st...

2010-02-13 07:27:43

program RadialWalk;
{.include SRL/SRL.scar}

var
road_color: T2DIntegerArray; // is this two dimensional array of intgers? Array of Array of Integer?
i, j: Integer;

procedure init_variables;
begin
SetupSRL;

SetArrayLength(road_color, 1);
road_color[0] := [8692140, 8823978, 8692135, 9021614, 8889771];
end;

begin
init_variables;

for i := 0 to High(road_color) do
begin
for j := 0 to High(road_color[i]) do
begin
if RadialRoadWalk(road_color[i][j], 60, 120, 72, 2, 2) then // expected Semicolon here
begin
WriteLn('Found: ' + IntToStr(road_color[i][j]));
break;
end else
begin
WriteLn('Could not find: ' + IntToStr(road_color[i][j]));
end;
FFlag(0);
end;
end;
end.
You can't do variable := [[]]; on two dimensional arrays

EDIT: And maybe you should do RadialRoadWalkTolerance()? That increases the chance of finding the correct color

void_hatred

2010-02-13 07:30:18

oh, sorry, and thank you!
coming from C-style languages I probably have a few bad habbits (well not bad, rather incorrect)

thanks a bunch!

void_hatred

Gu3st...

2010-02-13 07:31:20

From: void_hatred
oh, sorry, and thank you!
coming from C-style languages I probably have a few bad habbits (well not bad, rather incorrect)

thanks a bunch!

void_hatred
No problem :)
And you've learned fast! Good job (not many people with <10 posts know that much)

Frement

2010-02-13 07:33:29

Also try using ACA (AutoColor Aid?) Search for some tutorials, that way you can get pretty good autocolor function for roads and then use RadialWalkTolerance with tolerance as 2-5 or similar.