SRL Archive - Help and Support

DoorFinder


pwnaz0r

2007-02-20 19:52:20

Hey guys well im making a door finder for SRL membs community using alot of diff functions(not done yet). Anyways this is what I have so far.


program New;
{.include srl/srl.scar}

function DoorOpen : boolean;
var
DoortmpBox1,DoortmpBox2 : TBox;
Dx, Dy : integer;
SkipX1,Skipy1,SkipX2,SkipY2,SkipX3,SkipY3,SkipX4,SKipY4 : integer;
COSX, COSY : integer;
begin

COSX := 260;
COSY := 137;


If(FindColorFromCentre(Dx,Dy,COSX,COSY,1659242,100,10))then
begin
MMouse(Dx,Dy,1,1);
If(IsUpText('lose'))then
begin
result := true;
Exit;
end;
If(IsUpText('pen'))then
begin
result := false;
Exit;
end;
If not(IsUpText('pen'))and not(IsUpText('lose'))then
begin


SkipX1 := GetMousePos(x-20,y);
SkipY1 := GetMousePos(x,y-20);
SkipX2 := GetMousePos(x+20,y);
SkipY2 := GetMousePos(x,y+20);
DoortmpBox1 := cBox2(SkipX1,SkipY1,SkipX2,SkipY2);

If(FindColorSkipBoxTolerance(Dx,Dy,1659242,7,7,510,337,10,DoortmpBox1))then
begin
MMouse(Dx,Dy,1,1,);
If(IsUpText('lose'))then
begin
result := true;
Exit;
end;
If(IsUpText('pen'))then
begin
result := false;
Exit;
end;
If not(IsUpText('pen'))and not(IsUpText('lose'))then
begin


SkipX3 := GetMousePos(x-20,y);
SkipY3 := GetMousePos(x,y-20);
SkipX4 := GetMousePos(x+20,y);
SkipY4 := GetMousePos(x,y+20);
DoortmpBox2 := cBox2(SkipX3,SkipY3,SkipX4,SkipY4);

If(FindColorSkipBoxTolerance(Dx,Dy,1659242,7,7,510,337,10,DoortmpBox1))andIf(FindColorSkipBoxTolerance(Dx,Dy,1659242,7,7,510,337,10,DoortmpBox2))then
begin
MMouse(Dx,Dy,1,1,);
If(IsUpText('lose'))then
begin
result := true;
Exit;
end;
If(IsUpText('pen'))then
begin
result := false;
Exit;
end;
If not(IsUpText('pen'))and not(IsUpText('lose'))then
begin
result := true;
Writeln('Could Not Find Door.. Hope its Open');
Exit;
end;
end;
end;
end;
end;
end;
end;

begin
SetupSRL;
If(DoorOpen)then writeln('Door Open');
end.

And this is the error I get

Line 1: [Error] (1:1): Variable Expected in script

Boreas

2007-02-20 20:36:54

Check your begins and ends. Also, look for uptext door first, then decide whether it's 'pen' or 'lose'. Also see brambles door opener.

pwnaz0r

2007-02-20 20:51:37

From: Boreas
Also, look for uptext door first, then decide whether it's 'pen' or 'lose'.


I would but it has to find the door first the determine if its open or closed. It can be with find color bc then unless I called it again it wouldnt determine wether it was open or closed

Bramble

2007-02-21 23:34:37

ok what boreas was saying is, look for 'oor' first to see if ur pointer is on the door, then you look for a multi to see if its opened or closed, check this out, this is the function i made a while ago, feel free to use it or to build it into a multi functioning door opener(with backup procedures and such)

program New;
{.include srl/srl.scar}

Function MyOpenDoor(Dir:string):boolean;
var doorfound:string;i:integer;CoX:Array[0..8] of integer;
CoY:Array[0..8] of integer;
begin
Cox[0]:=326;
Coy[0]:=151;
Cox[1]:=246;
Coy[1]:=156;
Cox[2]:=186;
Coy[2]:=156;
Cox[3]:=330;
Coy[3]:=155;
Cox[4]:=273;
Coy[4]:=154;
Cox[5]:=219;
Coy[5]:=153;
Cox[6]:=306;
Coy[6]:=158;
Cox[7]:=281;
Coy[7]:=186;
Cox[8]:=217;
Coy[8]:=155;
keydown(40);
wait(1500);
keyup(40);
wait(500+random(+250));
makecompass(dir);
doorfound := 'no';
repeat
if (doorfound = 'no') then
begin
mmouse(Cox[i],Coy[i],3,3);
if (IsUpTextMulti('Door', 'Doo', 'oor') = true) then
begin
if (IsUpTextMulti('Open', 'Op', 'en') = true) or (isuptextmulti('Ope', 'pen', 'Open') = true) then
begin
GetMousePos(x,y);
mouse(x,y,0,0,true);
Doorfound := 'yes';
end;
if (IsUpTextMulti('Close', 'lo', 'se') = true) then
begin
Doorfound := 'yes';
end;
end;
end;
i:= +1;
until (i = 3) or (doorfound = 'yes');
if (doorfound = 'no') then
begin
keydown(38);
wait(200);
keyup(38);
wait(1000+random(250));
end;
repeat
if (doorfound = 'no') then
begin
mmouse(Cox[i],Coy[i],3,3);
if (IsUpTextMulti('Door', 'Doo', 'oor') = true) then
begin
if (IsUpTextMulti('Open', 'Op', 'en') = true) or (isuptextmulti('Ope', 'pen', 'Open') = true) then
begin
GetMousePos(x,y);
mouse(x,y,0,0,true);
Doorfound := 'yes';
end;
if (IsUpTextMulti('Close', 'lo', 'se') = true) then
begin
Doorfound := 'yes';
end;
end;
end;
i:= +1;
until (i = 6) or (doorfound = 'yes');
if (doorfound = 'no') then
begin
keydown(38);
wait(200);
keyup(38);
wait(1000+random(250));
end;
repeat
if (doorfound = 'no') then
begin
mmouse(Cox[i],Coy[i],3,3);
if (IsUpTextMulti('Door', 'Doo', 'oor') = true) then
begin
if (IsUpTextMulti('Open', 'Op', 'en') = true) or (isuptextmulti('Ope', 'pen', 'Open') = true) then
begin
GetMousePos(x,y);
mouse(x,y,0,0,true);
Doorfound := 'yes';
end;
if (IsUpTextMulti('Close', 'lo', 'se') = true) then
begin
Doorfound := 'yes';
end;
end;
end;
i:= +1;
until (i = 9) or (doorfound = 'yes');
if (doorfound = 'no') then
writeln('Couldnt open door, or door is allready open');
end;

begin
setupsrl;
activateclient;
MyOpenDoor('n');
end.

heres your version, that i have fixed so far, also made improvement to syntax

program New;
{.include srl/srl.scar}

function DoorOpen:boolean;
var DoortmpBox1,DoortmpBox2:TBox;Dx,Dy,COSX,COSY:integer;
SkipX1,Skipy1,SkipX2,SkipY2,SkipX3,SkipY3,SkipX4,SKipY4:integer;

begin
COSX := 260;
COSY := 137;
If(FindColorFromCentre(Dx,Dy,COSX,COSY,1659242,100,10))then
begin
MMouse(Dx,Dy,1,1);
If(IsUpText('lose'))then
begin
result := true;
Exit;
end;
If(IsUpText('pen'))then
begin
result := false;
Exit;
end;
If not(IsUpText('pen')) and not(IsUpText('lose'))then
begin
SkipX1 := GetMousePos(x-20,y);
SkipY1 := GetMousePos(x,y-20);
SkipX2 := GetMousePos(x+20,y);
SkipY2 := GetMousePos(x,y+20);
DoortmpBox1 := cBox2(SkipX1,SkipY1,SkipX2,SkipY2);
If(FindColorSkipBoxTolerance(Dx,Dy,1659242,7,7,510,337,10,DoortmpBox1))then
begin
MMouse(Dx,Dy,1,1,);
If (IsUpText('lose')) then
begin
result := true;
Exit;
end;
If(IsUpText('pen'))then
begin
result := false;
Exit;
end;
If not(IsUpText('pen'))and not(IsUpText('lose'))then
begin
SkipX3 := GetMousePos(x-20,y);
SkipY3 := GetMousePos(x,y-20);
SkipX4 := GetMousePos(x+20,y);
SkipY4 := GetMousePos(x,y+20);
DoortmpBox2 := cBox2(SkipX3,SkipY3,SkipX4,SkipY4);
If (FindColorSkipBoxTolerance(Dx,Dy,1659242,7,7,510,337,10,DoortmpBox1)) and (FindColorSkipBoxTolerance(Dx,Dy,1659242,7,7,510,337,10,DoortmpBox2)) then
begin
MMouse(Dx,Dy,1,1,);
If(IsUpText('lose'))then
begin
result := true;
Exit;
end;
If(IsUpText('pen'))then
begin
result := false;
Exit;
end;
If not(IsUpText('pen'))and not(IsUpText('lose'))then
begin
result := true;
Writeln('Could Not Find Door.. Hope its Open');
Exit;
end;
end;
end;
end;
end;
end;
end;

begin
SetupSRL;
If(DoorOpen)then writeln('Door Open');
end.

Avaphi

2007-02-22 19:52:13

Hmm Bramble, me thinks you need to change your Formatting on your scar to 2 space :P