SRL Archive - OSR Help

Help with a function please?


ne lg

2012-06-04 12:31:00

Hi, im trying to creat a death walker for Er1k's wilderness agility course, i've got pretty far but i'm at the part with the web and i have this so far:


if FindObj(x,y,'Web',9802901,10) then
Repeat
Mouse(x,y,3,3,true);
Wait(2000);
Until(


Untill what? i cant really think of a function that i know of to help, Obviously there is one, i only have like three or four functions that i use because i've only just watched YoHo's first scripting tutorial and attempted to make a deathwalker, if you read over my script so far you can see how little i know, lol.

Here is the full script


program new;
{$DEFINE SMART}
{.include SRL/SRL.simba}
{.include custom/DDTM.simba}
{.include SPS/SPS.simba}
const
SmartWorld = 7;
Members = False;
SignedClient = True;
HighDetail = False;
NumbOfPlayers = 1;
StartPlayer= 1;

procedure DeclarePlayers;
var i:integer;
begin
NumberOfPlayers(NumbOfPlayers);
CurrentPlayer := StartPlayer;
for i := 0 to NumbOfPlayers-1 do
Players[i].BoxRewards := ['mote', 'ostume', 'XP', 'Gem', 'ithril', 'oal', 'une', 'oins'];

with Players[0] do
begin
Name := ''; //Player username.
Pass := ''; //Player password.
Nick := ''; //Player nickname - 3-4 letters of Player username.
Active := True;

end;

end;

function FromEdgToArdy:boolean;
Var
EdgPath:TPointArray;
X,cx,vx,vy,cy,Y:integer;

begin;
ClickNorth(SRL_ANGLE_HIGH);
SPS_Setup(RUNESCAPE_SURFACE,['10_6','10_7']);
EdgPath := [Point(4244, 2662), Point(4217, 2658)];
SPS_WalkPath(EdgPath);
Wait(5000);
if FindObj(cx,cy,'Banker',5001645,30) then
begin;
Mouse(cx,cy,3,3,false);
ChooseOption('Bank Banker');
Wait(1000);
Withdraw(0,0,28);
CloseBank;
end else
begin;
Logout;
TerminateScript;
end;
GameTab(28);
if FindColorSpiralTolerance(x,y,8333644,564,222,586,240,10) then
begin;
Mouse(x,y,3,3,true);
end;
Wait(1000);
if FindColorSpiralTolerance(vx,vy,1579371,155,197,183,225,10) then
begin;
Mouse(vx,vy,3,3,true);
Wait(15000);
end;
end;
function FromArdyToWildy:Boolean;
var
ArdyPath:TPointArray;
x,qx,qy,y:integer;
begin;
ClickNorth(SRL_ANGLE_HIGH);
SPS_Setup(RUNESCAPE_SURFACE,['5_8','6_8','5_7','6_7']);
ArdyPath := [Point(2379, 3266), Point(2379, 3282), Point(2379, 3296), Point(2369, 3318), Point(2356, 3322), Point(2341, 3316), Point(2334, 3311), Point(2309, 3303), Point(2283, 3302), Point(2270, 3314), Point(2269, 3331), Point(2266, 3341), Point(2266, 3358), Point(2265, 3369), Point(2263, 3381), Point(2264, 3389), Point(2261, 3402), Point(2261, 3415), Point(2262, 3427), Point(2262, 3444), Point(2260, 3458), Point(2259, 3470), Point(2246, 3473), Point(2220, 3473), Point(2212, 3470), Point(2212, 3439), Point(2200, 3421), Point(2185, 3409), Point(2170, 3405), Point(2156, 3405), Point(2141, 3406), Point(2127, 3408), Point(2116, 3410), Point(2102, 3414), Point(2091, 3416)];
SPS_WalkPath(ArdyPath);
Wait(3000);
if FindObj(x,y,'Lever',4026508,10) then
begin;
Mouse(x,y,2,2,true);
Wait(5000);
end;
end;

function FromWildyToCourse:boolean;
var
WildyPath:TPointArray;
x,y:integer;
begin;
ClickNorth(SRL_ANGLE_HIGH);
SPS_Setup(RUNESCAPE_SURFACE,['11_2','10_2']);
WildyPath := [Point(4455, 934), Point(4457, 920), Point(4457, 913), Point(4457, 899), Point(4460, 888), Point(4462, 866), Point(4467, 848), Point(4467, 832), Point(4468, 825)];
SPS_WalkPath(WildyPath);
Wait(3000);
if FindObj(x,y,'Web',9802901,10) then
Repeat
Mouse(x,y,3,3,true);
Wait(2000);
Until(







begin
Smart_Server := SmartWorld;
Smart_Members := Members;
Smart_Signed := SignedClient;
Smart_SuperDetail := HighDetail;
setupSRL();
DeclarePlayers;
FromEdgToArdy;
FromArdyToWildy;
end.

I know is looks awful compaired to a real script but it acctually works so far when i tested it.

And anyway, it's not a full script just a death walk.

So TLDR: Any help with the slashing web part of a deathwalker?

Fascinate

2012-06-04 12:34:05

You could repeat until you do not find the DTM of the web. That would mean you have to make a DTM for the web though. Or if anything is in the chatbox after succesfully slashed or if you fail to slash it? If so you can use find text to detect if it's been slashed or not.

Abu

2012-06-04 12:35:15

Until the Uptext is gone?

Whatever the uptext is…

ne lg

2012-06-04 12:37:45

Kk, i know how to create a DTM of an object, but how would i write then?

Fascinate

2012-06-04 12:38:23

From: abu_jwka
Until the Uptext is gone?

Whatever the uptext is…


Yeah this is a pretty easy thing to do and it is as reliable as anything.

Runaway

2012-06-04 12:41:47

Try hiding public chat and checking for "successfully slashed" or whatever unique text pops up when you succeed.

EDIT: Only if the uptext doesn't work though, that's probably the better way.

ne lg

2012-06-04 12:42:15

Would the function

IsUpText

do this?

the discription in SRL is "Returns True if there is currently Uptext on the screen" does that mean it returns true if the uptext matched the string or if there is any uptext at all, Because after cutting the web there will still be "walk here" uptext

Fascinate

2012-06-04 12:43:11

From: Runaway
Try hiding public chat and checking for "successfully slashed" or whatever unique text pops up when you succeed.


See now that is what I suggested ;)

Well if 2 people suggested it then it's definately recommended! ;)

Abu

2012-06-04 12:44:07

From: ne lg
Would the function

IsUpText

do this?

the discription in SRL is "Returns True if there is currently Uptext on the screen" does that mean it returns true if the uptext matched the string or if there is any uptext at all, Because after cutting the web there will still be "walk here" uptext


So your'e telling me when you're cutting the web, the uptext is walk here?

Weird… oh well.

Runaway

2012-06-04 12:44:53

From: ne lg
Would the function

IsUpText

do this?

the discription in SRL is "Returns True if there is currently Uptext on the screen" does that mean it returns true if the uptext matched the string or if there is any uptext at all, Because after cutting the web there will still be "walk here" uptext


You should use WaitUptext(), it's the same thing but it will monitor the uptext for however long you want until it finds the uptext, or doesn't.

WaitUptext('eb', 500) will wait a maximum of 500 ms for the web uptext. If it find it right away it won't wait for the whole 500 ms.

Fascinate

2012-06-04 12:45:42

From: abu_jwka
So your'e telling me when you're cutting the web, the uptext is walk here?

Weird… oh well.


Maybe it's a right click to even see the slash option…?

ne lg

2012-06-04 12:47:29

No, after cutting the web there is still an uptext.

Im asking if the function "isUpText" will return true for all uptext's or will only return true for the uptext given within the parameters

i.e isUpText('Slash Web');


Also, another question i was going to ask which sounds silly even to me,

When writing a string in that has an aphostrophy what do you do?

I.e FindObj(x,y,123,'smithie's',10);

Abu

2012-06-04 12:48:25

From: ne lg
No, after cutting the web there is still an uptext.


But is it the same uptext

EDIT: And yes you can specify the UpText within IsUpText()

ne lg

2012-06-04 12:49:55

From: Runaway
You should use WaitUptext(), it's the same thing but it will monitor the uptext for however long you want until it finds the uptext, or doesn't.

WaitUptext('eb', 500) will wait a maximum of 500 ms for the web uptext. If it find it right away it won't wait for the whole 500 ms.


This makes good sence to me i think,

If i MoveMouse(x,y) where x and y has the values of where i foundobj (the web) then i say mouse(x,y) untill(waituptext('walk here',323131))

I.e, It will find web, hover over it, press web until uptext says walk here.


Does this make sence/ will work?

Abu

2012-06-04 12:51:24

Ok try something like this:

procedure CutWeb;
var
Uptext: String;
x, y: Integer;
begin
if FindObj(x,y,'Web',9802901,10) then
begin
Uptext := GetUpText; // Gets the current Uptext
repeat
Mouse(x,y,3,3,true);
Wait(2000);
Until (not GetUpText = Uptext); //repeat until the uptext changes
end;
end;


EDIT: Or with what Runaway said which should work better:
procedure CutWeb;
var
Uptext: String;
x, y: Integer;
begin
if FindObj(x,y,'Web',9802901,10) then
repeat
Mouse(x,y,3,3,true);
Wait(2000);
Until IsUptext('alk'); //repeat until the uptext is walk here
end;
end;

ne lg

2012-06-04 12:53:49

From: abu_jwka
Ok try something like this:

procedure CutWeb;
var
Uptext: String;
x, y: Integer;
begin
if FindObj(x,y,'Web',9802901,10) then
begin
Uptext := GetUpText; // Gets the current Uptext
repeat
Mouse(x,y,3,3,true);
Wait(2000);
Until (not GetUpText = Uptext); //repeat until the uptext changes
end;
end;



Thank, this is very helpful. I didnt even know you could use "not".

So can i use somthing like if not FindObj

Abu

2012-06-04 12:54:44

From: ne lg
Thank, this is very helpful. I didnt even know you could use "not".

So can i use somthing like if not FindObj


Yes you can.

Also read my edit.

ne lg

2012-06-04 12:59:29

From: abu_jwka
Yes you can.

Also read my edit.


Cool, and thanks allot for everyone's help :)

Runaway

2012-06-04 13:05:09

Just building on abu's code a little bit:


function CutWeb(WaitFor: Integer): Boolean;
var
Uptext: String;
t, x, y: Integer;
begin
Result := False;
MarkTime(t);
Writeln('Searching for web...');
repeat
if FindObj(x,y,'Web',9802901,10) then
begin
repeat
Mouse(x,y,3,3,true);
if WaitUptext('alk', 1000) then
begin
Writeln('Web slashed!');
Result := True;
Break;
end;
Wait(Random(1000));
until (TimeFromMark(t) > (WaitFor / 2));
end;
until Result or (TimeFromMark(t) > WaitFor);
if not Result then
Writeln('Web not found!');
end;

// I suggest using a WaitFor value of ~20000
if not CutWeb(20000) then
// Failsafe/Terminate

It's probably more efficient to make it a function.

Abu

2012-06-04 13:07:34

LOL, ^^^much more efficient :D