SRL Archive - OSR Help

Loops and order of operation/smithing


mafia miles

2013-04-13 17:02:11

Can you help me make this more stable, and loop friendly?
This is a personal script that goes to furnace in alkarid and smelts cballs. everything works but returning to bank and looping. Any tips? Editted out some of the code to be discreet.

program cballworking3;
{$DEFINE SMART8}
{$I SRL-OSR/SRL.Simba}
{$I SRL-OSR/SRL/Misc/Debug.Simba}

var
x, y, i: integer;
TPA : TPointArray;

Status:string;



const
AccountLogin = '';
AccountPass = '';
CharacterName = '';
version = '1.0';

procedure DeclarePlayer;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name := AccountLogin;
Players[0].Pass := AccountPass;
Players[0].Nick := CharacterName;
Players[0].Active := True;
end;









Procedure openBank;
begin
until (BankScreen);
end;



Procedure closeBank;
begin
end;

procedure Iswithdraw;
begin
openBankScreen;
wait(800 + random(800));
if bankscreen then
begin
writeln('banking');
wait(800 + random(800));
Deposit(2, 28, TRUE);
wait(500 + random(500));
begin
MMouse(142, 75, 2, 2);
wait(1200 + random(500));
begin
clickMouse2(mouse_right);
chooseOptionMulti(['All']);
writeln('WithDrawing');
wait(800 + random(800));

closeBank;
end;
end;
end;
end;


procedure WalkingToFurnace;
var
i,x,y:Integer;
begin
makecompass('N');
begin
RadialWalk(5012609,10,76,44,1,1); //click mm kebab
wait(2000);
RadialWalk(1732602,1,76,60,1,1); //click mm furnace
wait(2000);
makecompass('W');
end;
end;


procedure SmeltCBall;
var
pX, pY: integer;
begin
wait(5000);
Status := ('Doing Procedure clbar')
InvMouse(2, 1);
Writeln('clbar');
begin
Wait(1200 + Random(100));
MMouse(260, 95, 5, 5);
ClickMouse2(true);
wait(2000);
begin
//personal code here not ready to be released
begin


If FindSymbol(x,y,'Bank') then
begin
Mouse(x,y,1,1,true);
FFlag(0);
Writeln('Successfully completed Walking 1.');
wait(10000);
end else
Writeln('Walking failed!');
makecompass('S');
RadialWalk(5012609,5,76,35,1,1);

end;
end;
end;
end;
end;


begin
SetupSRL;
activateclient;
DeclarePlayer;
LoginPlayer;
wait(500);
repeat
walkingtofurnace;
SmeltCBall;
Iswithdraw;
until(false)
end.

Any tips on making it better? I tried using the option to findcustobj for clicking the furnace but i went with static coords on screen >.< any ideas on improving that?

mafia miles

2013-04-15 16:34:54

Updated. Please review post.

Kevin

2013-04-15 16:38:41

Instead of static co-ord clicking, I recommend using the ACA tool and using that to find most any object you want. It'll even write the full function for you to do it.

mafia miles

2013-04-15 16:44:13

Thanks! any idea on looping though? not sure how becides the simple main method loop.

Kevin

2013-04-15 16:49:07

As far as the main method loop goes, I don't see much of an issue with it. Except perhaps changing the until(false) to an until(not LoggedIn). (LoggedIn is the EOC method, idk the name of the 07 method).

Instead of using static co-ords to withdraw from your bank, you can use DTMs to find the desired object you wish to withdraw - or the simpler method is that bank slot dependent withdraw methods do exist actually and you can use them to withdraw from row 2 column 1 (or wherever).

mafia miles

2013-04-15 16:54:26

Thanks! Ill try It tonight :)

mafia miles

2013-04-16 10:21:59

The aca tool I used print autocolor and it didnt work in my script :( should i do print function instead?

Kevin

2013-04-16 10:26:06

When you're learning to use color and TPAs, you will find it easiest to use "print function." And you can even add an uptext to verify in that section.

Eventually as you improve, you will start using ACA to simply grab the color/tolerances/hue/sat you need.