SRL Archive - OSR Help

Help with my first script BoneBagAndBury


muu232

2012-10-03 01:07:13

This is the first script I've written for simba. I'm not sure what the problem is but I can't get the script to actually bury the bones. It will fill the inventory with bones but once it is full, it still tries to pick up bones and never changes procedures to bury them. Any advice would be appreciated.



program BoneBagAndBury;
{$define SMART}
{$i SRL\SRL.simba}

var
xp : Extended;
numBones, x, y, dtmBones: Integer;

const
SRLStats_Username = ' ';
SRLStats_Password = ' ';

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name := ' '; // Username
Players[0].Pass := ' '; // Password
Players[0].Nick := ' '; // 4 lowercase letters from your character name
Players[0].Active := True;
end;

procedure AntiBan;
begin
if(not(LoggedIn)) then
Exit;

If FindNormalRandoms Then
begin
Players[CurrentPlayer].Active := False;
NextPlayer(Players[CurrentPlayer].Active);
Exit;
end;

case Random(80) of
20: HoverSkill('prayer', False);
30: PickUpMouse;
40: RandomMovement;
50: BoredHuman;
60: ExamineInv;
end;
end;

procedure FindBones;

begin
if FindObj(x, y, 'Take', 10002613, 5)then
Mouse(x, y, 2, 0, False);
ChooseOption('ones');
end;

procedure BuryBones;
var
a : Integer;
begin
dtmBones:= DTMFromString('mggAAAHicY2NgYJjGxMAwE4gnA3EvEE8C4nlA/Bgodx+I70Hpl0D8FIg3rFjBsHjObIZpEyYAeUwM65YvY1gydy4DLsCIA0MAAAGqElA=');
a := CountItems('dtm', dtmBones, []);
if FindDTM(dtmBones, x, y, MIX1, MIY1, MIX2, MIY2) then
numBones := numBones + a;
Mouse(x, y, 0, 0, True);
end;

procedure StatusReport;
begin
xp := 4.5;
Writeln(' --- ');
Writeln(' BoneBagAndBury ');
Writeln(' Running For: ' + TimeRunning);
Writeln(' Bones Collected/Buried: ' + IntToStr(numBones));
Writeln(' Prayer XP Earned: ' + FloatToStr(numBones * xp));
Writeln(' --- ');
end;

procedure GetBones;
begin
repeat
FindBones;
AntiBan;
Wait(200);
until (InvFull);
WriteLn(' Bones Bagged ');
end;

begin
SRL_SixHourFix := True;
SMART_FixSpeed := True;

ClearDebug;
SetupSRL;
SetupSRLStats(439, SRLStats_Username, SRLStats_Password);
DeclarePlayers;

while (not (AllPlayersInactive)) do
begin
if not LoggedIn then
LoginPlayerToLob;
OpenWorldScreen;
SelectWorld(1);
LoginPlayer;
while(not LoggedIn) do
wait(1000);

MakeCompass(0);
SetAngle(SRL_ANGLE_HIGH);

while (LoggedIn) do
while (InvFull) do
repeat
BuryBones;
ClearDebug;
AntiBan;
Writeln(' Bones Buried ');
Writeln(' --- ');
StatusReport;
until (InvEmpty);
GetBones;
end;
end.

muu232

2012-10-03 02:08:43

well i got it halfway working.
I changed this procedure to:


procedure BuryBones;
var
a, x, y : Integer;
begin
dtmBones:= DTMFromString('mggAAAHicY2NgYJjGxMAwE4gnA3EvEE8C4nlA/Bgodx+I70Hpl0D8FIg3rFjBsHjObIZpEyYAeUwM65YvY1gydy4DLsCIA0MAAAGqElA=');
a := CountItems('dtm', dtmBones, []);
if(FindColorSpiralTolerance(x, y, 10987695, MIX1, MIY1, MIX2, MIY2, 15))then
numBones := numBones + a;
Mouse(x, y, 15, 15, True);
end;

But it only buries half the bones in the inventory then stops. The bone and xp counter isn't working correctly either but I'm more interested in getting the script functiong before I worry about fixing that. Any help please??

riwu

2012-10-03 05:26:54

You need a begin after conditional statement that is followed by >1 actions. You should load the DTM only once at start of the script (and free once at the end). At the current state you will crash simba within hrs.

while..do is already a loop so it shouldn't be followed by repeat, check the beginner tutorials on loops.

xtrapsp

2012-10-03 09:54:16

I suppose one thing I see is that you use while's and do's…


Ever considered using If and then?


if (InvEmpty) Then
begin
GetBones;
end else
writeln('Debug: Found Bones in Inventory OR Inventory is just full');
BuryBones;

What this does is detects if the inventory is empty then it will do the Procedure GetBones;
If the inventory is full then it will say it found bones in inventory or inventory is just full… this allows for fail safes like extra checks etc etc :P


You could also check if the inventory was just full of bones or if it had other items and if it has other items make it terminate the script.

:) Just as a fail safe.

muu232

2012-10-03 17:19:14

Thanks to both of you. Working on it now.