SRL Archive - First Scripts

My first simple willow power chopper.


Sawyer

2013-01-21 23:07:05

VERY SIMPLE willow power chopper. All suggestions/critiques are very welcome. :) *Please remember I'm just learning*
program PowerChopper;
{$DEFINE SMART8}
{$I SRL/SRL.Simba}

var
Status:String;
WillowsLost:Boolean;


procedure DeclarePlayers;
begin
Status := ('Logging in player.')
writeln('Logging in player.')
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

with Players[0] do
begin
Name := ''; // Player username
Pass := ''; // Player password
Active := True;
end;
end;

procedure SetupSmartClient;
begin
SRL_SixHourFix := True;
SMART_FixSpeed := True;

ClearDebug;
SetupSRL;
ActivateClient;
DeclarePlayers;
LoginPlayer;
end;

Procedure SetupBot;
begin
ClickNorth(0)
end;

Procedure Antiban; // Credit to Solidone40
Begin
Status :=('Antiban')

Case Random(100) Of
1: HoverSkill('woodcutting', False); //replace 'magic' with 'skill'
2: HoverSkill('random', False);
3: Boredhuman;
4: Wait(2500 + random(4500));
5: HoverSkill('random', False); // replace 'smithing' with 'skill', or delete.
6: PickUpMouse;
7: RandomMovement;
8: RandomRClick;
end;
end;

Function IsWoodcutting: Boolean; //Credit to Ubuntu
var
PBox: TBox;
begin
PBox := IntToBox(245, 130, 285, 195);
Result := (AveragePixelShift(PBox, 500, 650) > 400);
end;

Procedure CutWillows;
var
X,Y:Integer;
YewLocation:integer;
begin
Status :=('Finding and cutting willows.');
writeln('Finding and cutting willows.');
Repeat
While IsWoodcutting Do Wait(2000+Random(50));
if FindObjCustom(x, y, ['illow', 'own Wi'], [2502705, 2371118, 1976103], 20) then
Mouse(x, y, 4, 3, false);
ChooseOption('Will');
Until InvFull
begin
DropAll;
Case Random(3) Of
1: Antiban;
end;
end;
end;



begin
SetupSmartClient;
SetupBot;
Repeat
CutWillows;
Until(AllPlayersInactive)
WriteLn('Finishing Script.');
end.

Sjoe

2013-01-22 01:30:49

Looks good for your first script ! Try to learn more stuff now (like DTM's, Bitmaps, TPAs) or stuff with walking(SPS, RadialWalk) and banking!
And adding failsafes, very important too.

Loads of great tutorials in the tutorial section! Covering everything I mentioned

kyleinkman

2013-01-22 07:45:22

yeah looks good for a first script, if you dont want to add walking or banking, why not try burning them all after an inventory, that way you can make some firemaking xp too

Sawyer

2013-01-22 07:53:45

Alright. I'll work on it tonight after I get home from school.

Btw.. I have downloaded the ODTM extension, but whenever open simba it says
Object DTM Extension: Failed to grab remote extension.
Any suggestions?

kyleinkman

2013-01-22 08:11:43

did you enable it in the extensions menu?

Sawyer

2013-01-22 14:14:22

Yes I have. After I enable it, it says it cannot find remote extension. What is the link to the download that works**

t4q

2013-01-25 17:01:48

Looks nice, burning would be cooler than just droping them

KeepBotting

2013-01-29 20:20:32

Wait, what are WillowsLost and Status for?

You don't have a progress report, try putting this in:

procedure ProgressReport;
begin
ClearDebug;
Writeln('********************************************');
Writeln('* WillowPowerChopper *');
Writeln('********************************************');
Writeln('');
Writeln('Status: ' + Status + '.');
Writeln('');
Writeln('We have lost ' + IntToStr(WillowsLost) + ' willows. ');
Writeln('We have been running for ' + TimeRunning + '');
WriteLn('********************************************');
end;

Just do your MainLoop like this and you'll be set:

begin
SetupSmartClient;
SetupBot;
Repeat
ProgressReport;
CutWillows;
Until(AllPlayersInactive)
WriteLn('Finishing Script.');
end.

GuthixBoss1

2013-01-30 03:39:51

Small thing.. Your comments are wrong. :P

Sawyer

2013-02-16 18:44:55

Yup. I'd like to think I've vastly improved since I wrote this, as I have made a mahogany chopper that worked for a good 14 hours :)