SRL Archive - OSR Help

Repeating a procedure every "X" minutes


Frozenfire216

2012-08-29 17:15:32

Ok, so I have a question. How do you repeat a procedure every 5 minutes?



This code is not for Runescape, its for a different MMORPG.

My attacking and looting procedures work great, I don't need help on those, but in this game there are certain buffs your character can apply. These buffs are timed for 5 minutes. I have a procedure that applies these buffs and it works, but I need it repeated every 5 minutes.

The second issue is what should I use for a termination procedure so that whenever I hold down the "Delete" key, it terminates the script. Also, where should I use this procedure so i can terminate at ANYTIME?

Here's the code I have so far..

program Mob_Farmer;
{$i srl/srl.simba}

const
//various constants here

var
//various variables here


Procedure Terminate;
begin
//Script Termination Procedure, the second issue i need help with.
end;


Procedure Rebuff;
Begin
//this is the procedure I need repeated every 5 mins
end;

Procedure WaitScreen;
begin
//waits till I switch to client screen;
end;


Procedure Attack;
begin
//attack procedure
end;


Procedure Loot;
//loot procedure
end;


begin
SetUpSRL;
WaitScreen;
count:=0;
repeat
Attack;
Loot;
wait(50);
inc(count);
Writeln(intToStr(count)+ ' Mobs killed');
until (count=35000);
end.


Any help at all is appreciated! Thanks!

Runaway

2012-08-29 17:25:54

Hey Frozenfire,

To terminate the script at any time, you can press (Ctrl + Alt + S). As for the buffs:


procedure Rebuff;
begin
if (BuffTime = 0) or (TimeFromMark(BuffTime) > (5 * 60 * 1000)) then
begin
// Apply buff
MarkTime(BuffTime);
end;
end;

Declare BuffTime as a global var (integer) and call Rebuff every loop, like so:


begin
SetUpSRL;
WaitScreen;
count:=0;
repeat
Rebuff; // <--
Attack;
Loot;
wait(50);
inc(count);
Writeln(intToStr(count)+ ' Mobs killed');
until (count=35000);
end.

It will exit the Rebuff procedure if it hasn't been 5 minutes since the last time it applied buffs. Hope that helps :)

Frozenfire216

2012-08-29 17:33:41

That's exactly what I needed! Thanks for the very quick reply!

I have experience in programming in other languages, but this is my first script on Simba, so I'm not familiar with most of the commands.

Is there a thread with a list/explanation of most commands?

Once again, thanks!

Runaway

2012-08-29 17:41:04

From: Frozenfire216
That's exactly what I needed! Thanks for the very quick reply!

I have experience in programming in other languages, but this is my first script on Simba, so I'm not familiar with most of the commands.

Is there a thread with a list/explanation of most commands?

Once again, thanks!


No problem :)

You can check out the Simba bible here, a full list with desciptions of the built-in functions. You can also view them via the document browser in Simba (as well as SRL's library under 'Includes'):


Other than that, I'd say your best bet would be browsing working scripts.