SRL Archive - OSR Help

Surfaces include - how do use 2 objects?


rj

2013-04-21 18:59:07

@superuser

Does anyone know how to use 2 objects using his [http://villavu.com/forum/showthread.php?t=100227] include? I have

procedure InitRocks();
begin
SMART_ClearMS();

with surface_rock do begin
c := 1070711;
hm := 0.02;
sm := 0.19;
t := 6;
minw := 4; // At least 4 pixels wide.
maxw := 80; // No more than 80 pixels wide.
minh := 4; // At least 4 pixels tall.
maxh := 80; // No more than 80 pixel tall.
step := 9;
max_distance := 200;
end;

CreateSurfaceParts(obj_coal_rock, 2);

with obj_coal_rock do begin
// So, the first part we copy:
parts[0] := CopySurfacePart(surface_rock);

// And then the second one, which is the brown part in iron rock when it's not mined yet.
parts[1].c := 1251873;
parts[1].hm := 1.39;
parts[1].sm := 4.49;
parts[1].t := 6;
parts[1].filter := @SurfaceFilterClosest; // We want to have the closest iron rock next to us.
parts[1].minw := 5;
parts[1].maxw := parts[0].maxw;
parts[1].minh := 5;
parts[1].maxh := parts[0].maxh;
parts[1].step := 16;
parts[1].max_distance := parts[0].max_distance;

name := 'Coal ore';
uptext := 'Coal';
filter := @SurfaceFilterClosest;
end;


with surface_bank do begin
c := 6713206;
hm := 0.29;
sm := 0.08;
t := 5;
minw := 4; // At least 4 pixels wide.
maxw := 40; // No more than 80 pixels wide.
minh := 4; // At least 4 pixels tall.
maxh := 100; // No more than 80 pixel tall.
step := 9;
max_distance := 250;
end;

CreateSurfaceParts(obj_Deposite, 2);

with obj_deposite do begin
// So, the first part we copy:
parts[1] := CopySurfacePart(surface_bank);

// And then the second one, which is the brown part in iron rock when it's not mined yet.
parts[1].c := 6653336;
parts[1].hm := 0.11;
parts[1].sm := 0.39;
parts[1].t := 3;
parts[1].filter := @SurfaceFilterClosest; // We want to have the closest iron rock next to us.
parts[1].minw := 5;
parts[1].maxw := parts[1].maxw;
parts[1].minh := 5;
parts[1].maxh := parts[1].maxh;
parts[1].step := 16;
parts[1].max_distance := parts[1].max_distance;

name := 'Deposite booth';
uptext := 'deposite';
filter := @SurfaceFilterClosest;
end;
end;

But that does not seem to work

Olly

2013-04-21 19:24:59

"But that does not seem to work".. that's not much infomation, anything more?

rj

2013-04-21 19:38:12

From: Ollybest
"But that does not seem to work".. that's not much infomation, anything more?


It cannot find the booth, but when I enter the booth enter the top objects it works

King

2013-04-21 20:21:47

Doesnt he use a two part on in his example on the thread? Try just copy and pasting his example and changing for a bank booth and seeing if that works, might be a very small change or something.

rj

2013-04-21 21:39:08

From: King
Doesnt he use a two part on in his example on the thread? Try just copy and pasting his example and changing for a bank booth and seeing if that works, might be a very small change or something.


No :/

King

2013-04-21 21:44:47

From: Officer Barbrady
No :/


I thought he did with rock, then iron ore :P Or do you mean having Two different objects? Cause I couldnt get it to work with two different objects either ):

rj

2013-04-21 21:47:35

From: King
I thought he did with rock, then iron ore :P Or do you mean having Two different objects? Cause I couldnt get it to work with two different objects either ):


No that was 1 I want 2 different objects

King

2013-04-21 21:48:29

From: Officer Barbrady
No that was 1 I want 2 different objects


I couldnt get that to work either /:

rj

2013-04-21 21:53:14

From: King
I couldnt get that to work either /:


I can only get 1 to work, in his artic pines script he uses 3 objects but he does it in a different way

superuser

2013-04-22 04:04:42

Change

parts[1] := CopySurfacePart(surface_bank);

to

parts[0] := CopySurfacePart(surface_bank);

Also remember, that the second part has to be found inside the first one.

Edit:

Here's an example for Varrock booth:

program surfaces;

{$DEFINE SMART}

{$i srl\srl.simba}
{$i srl\srl\misc\SmartGraphics.simba}

{$i su_surfaces.simba}

var
obj_bank_booth: TSurfaceObject;

procedure Init();
begin
SetupSRL();
SMART_ClearMS();

CreateSurfaceParts(obj_bank_booth, 2);

with obj_bank_booth do begin
parts[0].c := 1785675;
parts[0].hm := 0.06;
parts[0].sm := 1.56;
parts[0].t := 5;
parts[0].minw := 30;
parts[0].maxw := 150;
parts[0].minh := 30;
parts[0].maxh := 100;
parts[0].step := 16;
parts[0].off_y := -5;
parts[0].max_distance := 999;

parts[1].c := 4284527;
parts[1].hm := 0.15;
parts[1].sm := 2.18;
parts[1].t := 6;
parts[1].filter := @SurfaceFilterClosest;
parts[1].minw := 1;
parts[1].maxw := parts[0].maxw;
parts[1].minh := 1;
parts[1].maxh := parts[0].maxh;
parts[1].step := 16;
parts[1].max_distance := parts[0].max_distance;

name := 'Bank booth';
uptext := 'ooth';
filter := @SurfaceFilterClosest;
end;
end;

begin
Init();

if FindSurfaceObject(obj_bank_booth, MSX1, MSY1, MSX2, MSY2) then with obj_bank_booth do begin
WriteLn('Found the ' + name + ' at ' + IntToStr(p.x) + ', ' + IntToStr(p.y));

MMouse(p.x, p.y, 2, 2);
end;
end.

And a screenshot:


rj

2013-04-22 05:22:33

From: superuser
Change

parts[1] := CopySurfacePart(surface_bank);

to

parts[0] := CopySurfacePart(surface_bank);

Also remember, that the second part has to be found inside the first one.

Edit:

Here's an example for Varrock booth:

program surfaces;

{$DEFINE SMART}

{$i srl\srl.simba}
{$i srl\srl\misc\SmartGraphics.simba}

{$i su_surfaces.simba}

var
obj_bank_booth: TSurfaceObject;

procedure Init();
begin
SetupSRL();
SMART_ClearMS();

CreateSurfaceParts(obj_bank_booth, 2);

with obj_bank_booth do begin
parts[0].c := 1785675;
parts[0].hm := 0.06;
parts[0].sm := 1.56;
parts[0].t := 5;
parts[0].minw := 30;
parts[0].maxw := 150;
parts[0].minh := 30;
parts[0].maxh := 100;
parts[0].step := 16;
parts[0].off_y := -5;
parts[0].max_distance := 999;

parts[1].c := 4284527;
parts[1].hm := 0.15;
parts[1].sm := 2.18;
parts[1].t := 6;
parts[1].filter := @SurfaceFilterClosest;
parts[1].minw := 1;
parts[1].maxw := parts[0].maxw;
parts[1].minh := 1;
parts[1].maxh := parts[0].maxh;
parts[1].step := 16;
parts[1].max_distance := parts[0].max_distance;

name := 'Bank booth';
uptext := 'ooth';
filter := @SurfaceFilterClosest;
end;
end;

begin
Init();

if FindSurfaceObject(obj_bank_booth, MSX1, MSY1, MSX2, MSY2) then with obj_bank_booth do begin
WriteLn('Found the ' + name + ' at ' + IntToStr(p.x) + ', ' + IntToStr(p.y));

MMouse(p.x, p.y, 2, 2);
end;
end.

And a screenshot:



Ahh ty So I can make 3 colors for it right?

superuser

2013-04-22 05:43:08

From: Officer Barbrady
Ahh ty So I can make 3 colors for it right?


Sure!

rj

2013-04-22 05:45:43

From: superuser
Sure!


wait it's not working -.-

procedure InitRocks();
begin
SMART_ClearMS();
CreateSurfaceParts(obj_coal_rock, 2);

with obj_coal_rock do begin
parts[0].c := 1070711;
parts[0].hm := 0.02;
parts[0].sm := 0.19;
parts[0].t := 7;
parts[0].minw := 4; // At least 4 pixels wide.
parts[0].maxw := 80; // No more than 80 pixels wide.
parts[0].minh := 4; // At least 4 pixels tall.
parts[0].maxh := 80; // No more than 80 pixel tall.
parts[0].step := 9;
parts[0].max_distance := 200;

parts[1].c := 1251873;
parts[1].hm := 1.39;
parts[1].sm := 4.49;
parts[1].t := 12;
parts[1].filter := @SurfaceFilterClosest; // We want to have the closest iron rock next to us.
parts[1].minw := 5;
parts[1].maxw := parts[0].maxw;
parts[1].minh := 5;
parts[1].maxh := parts[0].maxh;
parts[1].step := 16;
parts[1].max_distance := parts[0].max_distance;

name := 'Coal ore';
uptext := 'Coal';
filter := @SurfaceFilterClosest;
CreateSurfaceParts(obj_Deposite, 2);
end;
with obj_Deposite do begin
parts[0].c := 7042428;
parts[0].hm := 0.20;
parts[0].sm := 0.12;
parts[0].t := 5; //7
parts[0].minw := 1;
parts[0].maxw := 80;
parts[0].minh := 1;
parts[0].maxh := 130;
parts[0].step := 9;
parts[0].max_distance := 200;

parts[1] := CopySurfacePart(surface_bank)
parts[1].c := 6653593;
parts[1].hm := 0.11;
parts[1].sm := 0.43;
parts[1].t := 4; //5
parts[1].filter := @SurfaceFilterClosest;
parts[1].minw := 5;
parts[1].maxw := parts[1].maxw;
parts[1].minh := 5;
parts[1].maxh := parts[1].maxh;
parts[1].step := 16;
parts[1].max_distance := parts[1].max_distance;

name := 'Deposite booth';
uptext := 'deposite';
filter := @SurfaceFilterClosest;
end;
end;

It claims it cant find the booth

superuser

2013-04-22 05:49:04

From: Officer Barbrady
wait it's not working -.-

procedure InitRocks();
begin
SMART_ClearMS();
CreateSurfaceParts(obj_coal_rock, 2);

with obj_coal_rock do begin
parts[0].c := 1070711;
parts[0].hm := 0.02;
parts[0].sm := 0.19;
parts[0].t := 7;
parts[0].minw := 4; // At least 4 pixels wide.
parts[0].maxw := 80; // No more than 80 pixels wide.
parts[0].minh := 4; // At least 4 pixels tall.
parts[0].maxh := 80; // No more than 80 pixel tall.
parts[0].step := 9;
parts[0].max_distance := 200;

parts[1].c := 1251873;
parts[1].hm := 1.39;
parts[1].sm := 4.49;
parts[1].t := 12;
parts[1].filter := @SurfaceFilterClosest; // We want to have the closest iron rock next to us.
parts[1].minw := 5;
parts[1].maxw := parts[0].maxw;
parts[1].minh := 5;
parts[1].maxh := parts[0].maxh;
parts[1].step := 16;
parts[1].max_distance := parts[0].max_distance;

name := 'Coal ore';
uptext := 'Coal';
filter := @SurfaceFilterClosest;
CreateSurfaceParts(obj_Deposite, 2);
end;
with obj_Deposite do begin
parts[0].c := 7042428;
parts[0].hm := 0.20;
parts[0].sm := 0.12;
parts[0].t := 5; //7
parts[0].minw := 1;
parts[0].maxw := 80;
parts[0].minh := 1;
parts[0].maxh := 130;
parts[0].step := 9;
parts[0].max_distance := 200;

parts[1] := CopySurfacePart(surface_bank)
parts[1].c := 6653593;
parts[1].hm := 0.11;
parts[1].sm := 0.43;
parts[1].t := 4; //5
parts[1].filter := @SurfaceFilterClosest;
parts[1].minw := 5;
parts[1].maxw := parts[1].maxw;
parts[1].minh := 5;
parts[1].maxh := parts[1].maxh;
parts[1].step := 16;
parts[1].max_distance := parts[1].max_distance;

name := 'Deposite booth';
uptext := 'deposite';
filter := @SurfaceFilterClosest;
end;
end;

It claims it cant find the booth


That's because you are doing it wrong. You already defined the first part, hence

parts[1] := CopySurfacePart(surface_bank)

breaks it. Also, you have max-distance of 200 pixels, so anything more far won't be recognized.

Also, you wrote

parts[1].maxw := parts[1].maxw;

which means the maximum width of the surface is 0!

King

2013-04-22 11:27:02

From: superuser
Change

parts[1] := CopySurfacePart(surface_bank);

to

parts[0] := CopySurfacePart(surface_bank);

Also remember, that the second part has to be found inside the first one.

Edit:

Here's an example for Varrock booth:

program surfaces;

{$DEFINE SMART}

{$i srl\srl.simba}
{$i srl\srl\misc\SmartGraphics.simba}

{$i su_surfaces.simba}

var
obj_bank_booth: TSurfaceObject;

procedure Init();
begin
SetupSRL();
SMART_ClearMS();

CreateSurfaceParts(obj_bank_booth, 2);

with obj_bank_booth do begin
parts[0].c := 1785675;
parts[0].hm := 0.06;
parts[0].sm := 1.56;
parts[0].t := 5;
parts[0].minw := 30;
parts[0].maxw := 150;
parts[0].minh := 30;
parts[0].maxh := 100;
parts[0].step := 16;
parts[0].off_y := -5;
parts[0].max_distance := 999;

parts[1].c := 4284527;
parts[1].hm := 0.15;
parts[1].sm := 2.18;
parts[1].t := 6;
parts[1].filter := @SurfaceFilterClosest;
parts[1].minw := 1;
parts[1].maxw := parts[0].maxw;
parts[1].minh := 1;
parts[1].maxh := parts[0].maxh;
parts[1].step := 16;
parts[1].max_distance := parts[0].max_distance;

name := 'Bank booth';
uptext := 'ooth';
filter := @SurfaceFilterClosest;
end;
end;

begin
Init();

if FindSurfaceObject(obj_bank_booth, MSX1, MSY1, MSX2, MSY2) then with obj_bank_booth do begin
WriteLn('Found the ' + name + ' at ' + IntToStr(p.x) + ', ' + IntToStr(p.y));

MMouse(p.x, p.y, 2, 2);
end;
end.

And a screenshot:



Thanks for this, cleared up my issue(: I am having trouble with a Fairy ring though, suddenly couldnt recognize it, however I will try again with some more parts.

superuser

2013-04-22 12:32:18

From: King
Thanks for this, cleared up my issue(: I am having trouble with a Fairy ring though, suddenly couldnt recognize it, however I will try again with some more parts.


Pick more colors with ACA, should fix the issue.

King

2013-04-22 12:44:36

From: superuser
Pick more colors with ACA, should fix the issue.


Okay, will do(: Ill play around with it more tonight, Right now I have it finding based on ATPA'S split into certain Zoe's and its working okay, but surfaces work much better than my function :D

rj

2013-04-22 15:37:15

From: King
Okay, will do(: Ill play around with it more tonight, Right now I have it finding based on ATPA'S split into certain Zoe's and its working okay, but surfaces work much better than my function :D


Make it a high tolerance, it should be ok as long as you have 2 parts atleast

King

2013-04-22 15:47:30

From: Officer Barbrady
Make it a high tolerance, it should be ok as long as you have 2 parts atleast


Make the Surfaces a higher tolerance? :P

rj

2013-04-22 16:02:58

From: King
Make the Surfaces a higher tolerance? :P


parts[1].t            := 13;   //4

Yes. Also use hella lot of colors

King

2013-04-22 16:07:37

From: Officer Barbrady
parts[1].t            := 13;   //4

Yes. Also use hella lot of colors


Okay!