SRL Archive - First Scripts

First script - auto basketer


cadet54

2014-04-30 16:27:11

Hi this is my first try at scripting, I have followed the guide on the help and tutorials section thanks to Mayor.
I have been making a bit of profit from buying fruit and then putting them in baskets, the profit vary's depending on what the GE prices are like. If you see your code in here im sorry but its probably stolen from a script you wrote :P.

To set this is up you need to use preset 2, in this preset you want 4 baskets in the first 4 slots followed by fruit for the rest of the slots. The basket should be assigned to quick-slot 1 on the quick-slot bar.

THE ONLY BANK SUPPORTED AT THE MOMENT IS DRAYNOR

I am just looking for feedback and criticism on my code before I start on my other goal of making a master farmer pickpocketer followed by a dragon slayer script (not sure which dragon yet).

I am by no means competent at scripting and I hardly understand it, but over time I may get better.

This is from using apples
========================================================
Cadets auto basketeer
Time Run: 20 Minutes and 54 Seconds
Baskets Filled: 724
Loads Done: 181
Profit Made: 289600
Per Hour: 830883
========================================================

program Basketeer;

{$DEFINE SMART}
{$I SRL-6/SRL.simba}
{$I SPS/lib/SPS-RS3.Simba}

var
LoadsDone, Slot, x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;

///*//////////////////////Start of player set up\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*\\\
Const
QuickKey = 1; //The slot in which the basket is asigned to
ProfitPB = 400; //The amount of profit per basket filled, depends on fruit
bankPin = ''; //Your bank pin
BankLoc = BANK_NPC_DRAYNOR; //Change depending on the bank you are using

procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := ''; //Enter user name here
password := ''; //Enter password here
isActive := true;
isMember := true;
end;
currentPlayer := 0;
end;
///*//////////////////////End of player set up\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*\\\

Procedure FindNormalRandoms;
Begin
exitTreasure();
claimTicket();
End;

procedure progressReport();
var
basketFilled, profit, profitPerHour: integer;
begin
basketFilled := LoadsDone * 4;
profit := (basketFilled * ProfitPB);
profitPerHour := round((profit * 60) / (getTimeRunning() / 60000));

writeLn('========================================================');
writeLn('Cadets auto basketeer');
writeLn('Time Run: ' + timeRunning);
writeLn('Baskets Filled: ' + intToStr(basketFilled));
writeLn('Loads Done: ' + intToStr(loadsDone));
writeLn('Profit Made: ' + intToStr(profit));
writeLn('Per Hour: ' + intToStr(profitPerHour));
writeLn('========================================================');
end;

procedure openBank();
begin
bankScreen.open(BankLoc);
if (pinscreen.isOpen()) then
writeln('Pinscreen is open!');

if (pinScreen.enter(bankPin)) then
writeln('Entered our bank pin!');

if not bankScreen.isOpen then
wait(650);

begin
if bankScreen.isOpen then
exit;
findColorsSpiralTolerance(x, y, TPA, 5385548, mainScreen.getBounds(), 16, colorSetting(2, 0.59, 0.72));

if (Length(TPA) < 1) then
exit;

ATPA := TPA.toATPA(30, 30);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(ATPA);
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['anker'], 500) then
begin
fastClick(MOUSE_LEFT);
break;
end;
end;
end;
end;

procedure withdrawPreset();
begin
if (bankScreen.isOpen()) then
begin
bankScreen.clickButton(BANK_BUTTON_PRESET_2);
end;
inc(LoadsDone);
end;
procedure fillBasket();
var
timesTried:integer;
T: TTimeMarker;
begin
FindNormalRandoms;
If Not IsLoggedIn Then
Exit;

If TabBackpack.IsEmpty then
Exit;

T.Start;
Repeat
SendKeys(ToStr(QuickKey), 60 + Random(60), 60 + Random(60));
Wait(GaussRangeInt(50,100));

If Not IsLoggedIn Then
Exit;

If T.GetTime>15000 Then
Exit;
Until (T.GetTime>1450);
End;


{Main Loop}
begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
declarePlayers();

repeat
if not isLoggedIn() then
begin
players[currentPlayer].login();
exitSquealOfFortune();
Minimap.ClickCompass;
MainScreen.SetAngle(MS_ANGLE_HIGH);
end;

openBank();
Wait(RandomRange(500,1500));
withdrawPreset();
Wait(RandomRange(100,500));
fillBasket();
Wait(RandomRange(1700,2200));
progressReport();
until (false);
end.

Olly

2014-04-30 17:04:58

Nice first script, but I saw this.

if bankScreen.isOpen then
bankTimer.start();
exit

Shouldn't that be

if bankScreen.isOpen then
begin
bankTimer.start();
exit;
end;

Since currently it will exit 100% of the time. :p

cadet54

2014-05-01 01:24:27

From: Olly
Nice first script, but I saw this.

if bankScreen.isOpen then
bankTimer.start();
exit

Shouldn't that be

if bankScreen.isOpen then
begin
bankTimer.start();
exit;
end;

Since currently it will exit 100% of the time. :p


Balls, thanks didn't notice that.

The Mayor

2014-05-01 02:20:18

Nice first script :D It would be a good idea to put the bank and pin as constants so the user doesn't have so scroll half way down to input the info. A few little things:

You should probably start using exitTreasure and claimTicket as the other ones were for SOF and will eventually be removed from SRL6.

procedure findNormalRandoms();
begin
exitTreasure();
claimTicket();
end;

Don't need a begin and end here, since there is just 1 statement after the then (or were you meant to put the inc inside the begin..end?).

procedure withdrawPreset();
begin
if (bankScreen.isOpen()) then
begin
bankScreen.clickButton(BANK_BUTTON_PRESET_2);
end;
inc(LoadsDone);
end;

E: What's your bankTimer for :p

cadet54

2014-05-01 11:10:54

From: The Mayor
Nice first script :D It would be a good idea to put the bank and pin as constants so the user doesn't have so scroll half way down to input the info. A few little things:

You should probably start using exitTreasure and claimTicket as the other ones were for SOF and will eventually be removed from SRL6.

procedure findNormalRandoms();
begin
exitTreasure();
claimTicket();
end;

Don't need a begin and end here, since there is just 1 statement after the then (or were you meant to put the inc inside the begin..end?).

procedure withdrawPreset();
begin
if (bankScreen.isOpen()) then
begin
bankScreen.clickButton(BANK_BUTTON_PRESET_2);
end;
inc(LoadsDone);
end;

E: What's your bankTimer for :p


Thanks for the reply Mayor, um the timer was something I started but forgot about and haven't yet remembered what I was going to do with it :P.

I will put in the bank pin as a constant as well as the profit per basket. Maybe even the bank you are using. I will put up an updated version soon.

I might even experiment with player forms just so I have an idea of how to use it in my next script.

cadet54

2014-05-01 15:07:18

Updated the script a bit according to the feedback of the Mayor and Olly, anything else that could be handled better or improved upon is much appreciated.