SRL Archive - SRL Old School RuneScape

I Think I Need A Timer Or Something


S_rose94

2013-11-07 10:30:22

Basically the issue I am having is that my woodcutting bot works however it has a tendency to run around to the point where it runs to an area where it can only see one tree on the screen, this is probably because Im using spiral Tolerance instead of DTM but that's because i cant get my DTM to work, so what i was thinking of doing is due to the fact that I have implemented code so that the bot knows if it is chopping a tree or not (chopping :=0 , chopping :=1) that if i had a timer I could set it so that if the bot has not chopped a tree for more than 10 seconds it will path walk back to the center of the forest and try again, does anybody have any ideas on how i can do this?

bonsai

2013-11-07 11:46:30

The basic method would be to set a variable to the current time plus your 10 second timeout:

timeout := GetSystemTime() + 10000;

Then in the code check 'if GetSystemTime() >= timeout'

There's an SRL6 class called TTimeMarker that is good for this, but I see you're posting in OSR so I assume you won't have that available in your script.

S_rose94

2013-11-07 13:03:51

I can get that to compile but not work

footballjds

2013-11-07 13:51:38

From: S_rose94
I can get that to compile but not work


post the code and I'll do it for you or help you learn

S_rose94

2013-11-08 17:00:00

This is my code for the script for the timer, :/ Thanks in advance (Also if there is any confusion please email me, i know it may look really messy but its my first script

Stuart

program Chopper;
{$Define Smart8}
{$I SRL-OSR/SRL.Simba}
{$i SPS/SPS.simba}
{$I SRL-OSR/SRL/misc/SmartGraphics.simba}



var
Tree, x, y: Integer;
HpBox:TBox;
chopping: Integer;
InvNeed: Integer;
AntiFreq: Integer;



Procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := '';
Pass := '';
Nick := ''; // You have to add your nickname
Pin := '';
Active := True;
end;
HpBox := IntToBox(230,129,289,170);
end;

procedure FindTree;
var x, y: Integer;
var chopping: Integer;
var InvNeed: Integer;

begin
if findobj(x ,y,'ree',3627893,15) then
begin
Mouse(x, y, 4, 4, False);
ChooseOption('hop');
InvNeed := InvCount +1;
Writeln('We are chopping!');
Repeat
begin
chopping := 1;
end;
until(InvNeed = InvCount); // or timer = 15 seconds
Begin
chopping := 0;
end;
// else Pathwalk
end else
Writeln('Not Found');
MakeCompass(Random(50));
end;
// If InvCount = 28 Bankwalk

Procedure Antiban;
var Antifreq: Integer;

begin
case random(AntiFreq) of
0: HoverSkill('woodcutting', false);
1: MakeCompass(RandomRange(0,359));
2: BoredHuman;
3: RandomRClick;
end;
end;

Procedure FullInv;
Var
MyPath:TPointArray;
begin
If InvFull Then
begin
Writeln('Full');
SPS_Setup(RUNESCAPE_SURFACE,['11_9']);
MyPath := [Point(4496, 3733), Point(4563, 3654), Point(4659, 3655),
Point(4727, 3696), Point(4721, 3730), Point(4670, 3730),
Point(4655, 3708), Point(4628, 3690)];
SPS_WalkPath(MyPath);
end;
end;

Begin
DeclarePlayers;
SetupSRL;
LoginPlayer;
ClearDebug;
repeat
begin
if chopping = 0 then
FindTree;
Antiban;
FullInv;


end
until(false)
end.

footballjds

2013-11-09 11:43:02

i don't think you can use SPS for OSR? unless im outdated

S_rose94

2013-11-09 17:29:51

From: footballjds
i don't think you can use SPS for OSR? unless im outdated

Think that may be the case trying to get it to run with DTM's, it completes the first movement skips the rest :P

footballjds

2013-11-11 09:01:56

where are you doing this at?