SRL Archive - OSR Help

How can I repeat until finding a DTM or Color?


J J

2012-02-26 16:48:15

== HAS BEEN ANSWERED ==


I'm working on a thieving script. Once you succesfully thieved a chest you have a chance that this message will pop up.


I have already scripted my way that the script understands that the chest has been succesfully looted if that message doesn't pop up. But it blocks chatbox and Simba can no longer read it to check if it has been succesful.

How can I repeat my script until it has found this message? I was thinking of using something with color or a DTM. But my attempts have resulted into failed compiling so I'm looking for some help. This is my starting so far.

begin

ActivateClient;
SetUpSRL;
repeat
OpenChest;
repeat
CheckFail;
until(FindChatBoxText('open', 7, clBlack)) or
(FindChatBoxText('open', 8, clBlack))
until(false)

end.

Thanks in advance.

EDIT: here is the whole script so far
program ReadText;
{$i srl/srl.simba}

Function OpenChest:Boolean;
Var
X, Y: Integer;

begin
X:=MSCX;
Y:=MSCY;
if FindObjTPA(X, Y, 7442344, 5, 1, 4, 9, 20, ['ract']) then
begin;
Writeln('We found the chest');
GetMousePos(X, Y);

Case Random(4) of
0: begin;
Mouse(X, Y, 5, 5, True);
Writeln('We clicked the chest');
Wait(8000+random(1000));
end;

1: begin;
Mouse(X, Y, 5, 5, True);
Writeln('We clicked the chest');
Wait(8000+random(1000));
end;

2: begin;
Mouse(X, Y, 5, 5, True);
Writeln('We clicked the chest');
Wait(8000+random(1000));
end;

3: begin;
Mouse(X, Y, 5, 5, False);
WaitOption('Open', 300);
Writeln('We clicked the chest');
Wait(8000+random(1000));
end;
end;
end;
end;

procedure GreenBox;
Var
X, Y:Integer;

begin
if FindColorSpiralTolerance(X, Y, 1137204, 220, 457, 298, 479, 20) then
begin
MMouse(x, y, 5, 5);
Mouse(x, y, 0, 0, True);
Wait(1500+random(1000));
end;
end;


function CheckFail:Boolean;
Var
X, Y: Integer;

begin
if(FindChatBoxText('fail', 8, clBlack)) then
begin;
Writeln('We failed to open the chest, trying again');
FindObjTPA(X, Y, 7442344, 5, 1, 4, 9, 20, ['ract']);
GetMousePos(X, Y);
end;

if(FindChatBoxText('fail', 8, clBlack)) then

Case Random(2) of
0: begin;
Mouse(X, Y, 5, 5, True);
Writeln('We clicked the chest');
Wait(8000+random(1000));
end;

1: begin;
Mouse(X, Y, 5, 5, False);
WaitOption('Open', 300);
Writeln('We clicked the chest');
Wait(8000+random(1000));
end;
end;
end;

begin

ActivateClient;
SetUpSRL;
repeat
OpenChest;
repeat
CheckFail;
until(FindChatBoxText('open', 7, clBlack)) or
(FindChatBoxText('open', 8, clBlack))
until(false)

end.
If anyone has tips to make the script shorter it would be appreciated aswell.

tehq

2012-02-26 16:54:12

You could use my through DTM which is a DTM of the green box. And repeat until you find that DTM in the chat box.

I can post it here if you wish

J J

2012-02-26 16:57:00

From: tehq
You could use my through DTM which is a DTM of the green box. And repeat until you find that DTM in the chat box.

I can post it here if you wish

I was thinking of using something similiar like that. However, if I add it to the repeating loop it won't compile because I haven't defined X and Y.

Can you add it to my script and post it? :)

tehq

2012-02-26 17:04:55

From: RuneScapeJJ
I was thinking of using something similiar like that. However, if I add it to the repeating loop it won't compile because I haven't defined X and Y.

Can you add it to my script and post it? :)


Just did this very quick so you should check it (not sure if i put it in the loop you wanted me to ;) )

program ReadText;
{$i srl/srl.simba}

var
X, Y, ThroughDTM: Integer;


Procedure LoadDTM;

begin

ThroughDTM := DTMFromString('mbQAAAHicY2VgYFjAzMBwAogbgbgBiE8C8TwmBoZpULwEiq2TRRgYmZgZ8sJsGMrCLRguXrzIgA0wYsFgAAA+hQuY');

end;
Function OpenChest:Boolean;
Var
X, Y: Integer;

begin
X:=MSCX;
Y:=MSCY;
if FindObjTPA(X, Y, 7442344, 5, 1, 4, 9, 20, ['ract']) then
begin;
Writeln('We found the chest');
GetMousePos(X, Y);

Case Random(4) of
0: begin;
Mouse(X, Y, 5, 5, True);
Writeln('We clicked the chest');
Wait(8000+random(1000));
end;

1: begin;
Mouse(X, Y, 5, 5, True);
Writeln('We clicked the chest');
Wait(8000+random(1000));
end;

2: begin;
Mouse(X, Y, 5, 5, True);
Writeln('We clicked the chest');
Wait(8000+random(1000));
end;

3: begin;
Mouse(X, Y, 5, 5, False);
WaitOption('Open', 300);
Writeln('We clicked the chest');
Wait(8000+random(1000));
end;
end;
end;
end;

procedure GreenBox;
Var
X, Y:Integer;

begin
if FindColorSpiralTolerance(X, Y, 1137204, 220, 457, 298, 479, 20) then
begin
MMouse(x, y, 5, 5);
Mouse(x, y, 0, 0, True);
Wait(1500+random(1000));
end;
end;


function CheckFail:Boolean;
Var
X, Y: Integer;

begin
if(FindChatBoxText('fail', 8, clBlack)) then
begin;
Writeln('We failed to open the chest, trying again');
FindObjTPA(X, Y, 7442344, 5, 1, 4, 9, 20, ['ract']);
GetMousePos(X, Y);
end;

if(FindChatBoxText('fail', 8, clBlack)) then

Case Random(2) of
0: begin;
Mouse(X, Y, 5, 5, True);
Writeln('We clicked the chest');
Wait(8000+random(1000));
end;

1: begin;
Mouse(X, Y, 5, 5, False);
WaitOption('Open', 300);
Writeln('We clicked the chest');
Wait(8000+random(1000));
end;
end;
end;

begin

ActivateClient;
SetUpSRL;
repeat
OpenChest;
LoadDTM;
repeat
CheckFail;
until(FindChatBoxText('open', 7, clBlack) or FindDTM(ThroughDTM, x, y, MCX1, MCY1, MCX2, MCY2));
until(false)
FreeDTM(ThroughDTM);
end.

J J

2012-02-26 17:07:18

I see. You basicly defined Var X, Y outside of a procedure/function. Which means that it can succesfully compile it at the loop at the end of the script? Because it was giving me an error with the X and Y at the repeat loop. I'll test it out right now. It did compile :)

EDIT: Thanks, it works now.
I think my own way would have worked if I defined the Var X, Y outside of my procedures/functions. Just right at the start. I'll test that out tomorrow to see if I understand it. Well this way works so now I can work on opening some jails. It's opening the chests flawless now :) (Thieving Guild).

Thanks.

tehq

2012-02-26 17:12:12

From: RuneScapeJJ
I see. You basicly defined Var X, Y outside of a procedure/function. Which means that it can succesfully compile it at the loop at the end of the script? Because it was giving me an error with the X and Y at the repeat loop. I'll test it out right now. It did compile :)

EDIT: Thanks, it works now.
I think my own way would have worked if I defined the Var X, Y outside of my procedures/functions. Just right at the start. I'll test that out tomorrow to see if I understand it. Well this way works so now I can work on opening some jails. It's opening the chests flawless now :) (Thieving Guild).

Thanks.


No problem, and good luck with this script!

bg5

2012-02-26 18:48:21

But it blocks chatbox and Simba can no longer read it to check if it has been succesful.


if FindText(x, y, 'hanky', UpChars, MCX1, MCY1, MCX2, MCY2) then // If find this message then...
begin
KeyDown(32); // Press Space
wait(10+random(40));
KeyUp(32);
end;

Er1k

2012-02-27 02:24:48

Why dont you just press spacebar if this appears? It's definitely something there in SRL, called ClickContinue?

J J

2012-02-28 15:44:12

From: nosaj.421
Why dont you just press spacebar if this appears? It's definitely something there in SRL, called ClickContinue?

Yes it has been posted above, but there is no need to waste time by clicking on something. It is just something as a failsafe to know that it did succesfully thieved the chest.