SRL Archive - OSR Help

My First Script, Is a failure...


Saint//+

2013-02-26 18:19:30

I was making a PowerChopper/Log burner that cuts the evergreens west of barbarian Village
I started by looking at YoHoJo's tut and reading other tutorials to get what i have now, and i need to read a lot more :)
What im looking for is a finger pointing me in the right direction to look for more good Tut's

So far from my testing of this script over the past 2 days these are the bugs i have found.
1.)If it misses bonfire button it has to go through a wait to try and press it again, although sometimes it just goes back to cutting a log cuts one then tries to light a new fire and go through the process again
- i used Dtms to find the buttons and after clicking i dont know where to begin with a failsafe to check if its adding log to the fire before waiting for Complete. maybe adding

2.) When adding logs to the bonfire it does not burn all logs in the inventory
-I think this could be solved in a similar way to #1 ?

3.) When checking to see if it lit a fire it would find other fires around and move to next step.
-What would i use to make sure when its lighting a fire that it only looks for the fire im lighting incase there are other fires around? like a way so that it only searches for fire in a certain radius from center?

4.) When cutting trees it just walks where ever and eventually away from any cutable trees
- Is there anyway to anchor the player to a certain area?

5.) It does not log in
- I read some tuts on how to script a log in function but they went completely over my head, im looking for more tuts now and hopefully the more i read the better i will understand but if you know of any good tuts or just in general tips for this it would be much appreciated.


Thank you in advance im going to do a total rewrite of this script after I figure out what i'm missing and what I can improve on.

well here is the code for my script

program ChopUntilYouDropOrBurn;
{$Define Smart}
{$i srl/srl.simba}
Const
Playfor=30; /// How Long you want script to run in minutes \\\
BurnLogs='True'; ////Set to False for PowerChopper\\\\
Skiller='False'; ////If true have axe in 1st inv spot\\\\


//Much thanks to AwkwardSaws Handbook of useful functions
//Much Thanks to YohoJo, Abu_jwka, Solidone 40, and DannyRS -- Cited by procedures


//Doesnt support logging in anyway -.-'
Procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active:=True;
end;

Var
Runtime:Integer;
LogsCut:Integer;

//says on simba what script is doing --Thanks to YoHoJo Video Tut --
Procedure Statsguise(wat:string);
Begin
Status(wat);
Disguise(wat);
End;


//Anti-Ban -- Much Thanks to Solidone 40's Antiban Tutorial and DannyRS Advice --
procedure AntiBan;
begin
Statsguise('antiban')
if(not(LoggedIn))then
Exit;
FindNormalRandoms;
case Random(300) of
0:
begin
HoverSkill('Woodcutting', false);
wait(2400+Random(432));
end;
1: PickUpMouse;
2: MakeCompass('n');
3: BoredHuman;
4: RandomRClick;
5: RandomMovement;
6:
Begin
PickupMouse;
Case Random(12) of
1: RandomRClick;
2: RandomMovement;
End;
End;
end;
end;

//Cuts Logs --Much Thanks To YohoJO Video Tut--
Procedure Chop;
Var
x, y, PlusOne, TreeCounter: Integer;
Begin
PlusOne:= InvCount + 1;

x:=MSCX;
y:=MSCY;
If FindObjTPA(x, y, 794138, 6, 1, 15, 15, 70, ['Chop']) Then
Begin
Statsguise('Chopping')
GetMousePos(x, y)

Case Random(2) of
0: //Right Click
Begin
Mouse(x, y, 3, 3, false);
WaitOption('hop', 500);
End;
1: //Left Click
Begin
Mouse(x, y, 6, 6, True);
End;
End;

End;

Flag;
MarkTime(TreeCounter);

Repeat
Antiban;
Wait(2500 + Random(650))
If InvCount=Plusone then
Begin
Statsguise('got one');
Inc(logscut);
GetTimeRunning;
End;
If Invfull = True then
Break;
Until (invcount=PlusOne) or (TimeFromMark(TreeCounter) > 5000)
End;

//Drops Logs
Procedure Droplogs;
Begin
Statsguise('Dropping Logs')
If Invfull = True Then
Begin
If Skiller='True' Then //drops all but 1st inv spot
DropArray([2,3,4,8,7,6,5,9,10,11,12,16,15,14,13,17,18,19,20,24,23,22,21,25,26,27,28])
Else
Dropall; //Drops everything
End;
End;

//Adds to bonfire -- Buggy
Procedure Addtofire;
Var
X, y: Integer;
Begin
Statsguise('adding Logs')
IF FindObjTPA(x, y, 2177099, 8, 1, 5, 5, 10, ['raft']) Then // Clicks Log icon on Action bar
Mouse(x, y, 4, 4, True);
Wait(2000 + Random(1500))
IF FindObjTPA(x, y, 2177099, 8, 1, 5, 5, 10, ['elect']) Then //Clicks log icon on craft menu
Mouse(x, y, 4, 4, True);
Wait(120000 + Random(1500))
End;

//lights Fire -- Buggy
Procedure light;
Var
x, y: Integer;
Begin
Statsguise('Lighting fire')
If invfull = True Then
Begin
MouseItem(28, Mouse_Right);
WaitOption('ight', (400));
Wait(5000 + Random(2000));
Begin
If FindObjTPA(x, y, 3054840, 10, 1, 5, 5, 20, ['more']) Then
WriteLn('Found the Fire!!!!');
Wait(1000)
Addtofire;
End;
End;

End;

//not finished might complete if Rewriting Script
//Thanks To Abu_Jwka, even though i didn't do his tut justice here
Procedure Proggy;
Var
ScriTime: Integer;
Begin
ClearDebug;
GetTimeRunning
Scritime:=(GetTimeRunning/1000)
Writeln('~~~Leechs Chop N Drop or Burn~~~');
Writeln('Logs cut:' + IntToStr(Logscut));
Writeln('Time running:' + IntToStr(Scritime))

End;
//Main Loop
begin
ClearDebug;
SetUpSRL;
ActivateClient;
DeclarePlayers;
MarkTime(RunTime)
ClickNorth(SRL_ANGLE_HIGH)
Repeat
Begin
Chop; //chopstree)
Proggy;
End;
If Burnlogs='False' Then
Begin
Droplogs; //Drops logs
Proggy;
End
Else
Repeat
Light; //starts Bonfire
Proggy;
Until invempty = False;
Until TimeFromMark(RunTime) > ((playfor * 1000)*60)

end.

The Mayor

2013-02-26 18:29:45

First of all, congratulations on contradicting your username :)

I guess the easiest way to login your player would be to include LoginPlayer in your main loop:

begin
ClearDebug;
SetUpSRL;
ActivateClient;
DeclarePlayers;
LoginPlayer;
MarkTime(RunTime)
ClickNorth(SRL_ANGLE_HIGH)

Saint//+

2013-02-26 19:02:03

From: The Mayor
First of all, congratulations on contradicting your username :)

I guess the easiest way to login your player would be to include LoginPlayer in your main loop:


Thanks :) hopefully i'll learn enough soon to be confident about writing a monkfisher for my main.

it's really that simple -_-'
will that work the same way if its in the lobby of the game? and not the login screen?

The Mayor

2013-02-26 19:08:59

From: Megaleech
Thanks :) hopefully i'll learn enough soon to be confident about writing a monkfisher for my main.

it's really that simple -_-'
will that work the same way if its in the lobby of the game? and not the login screen?


Yep it should work from the lobby.

Saint//+

2013-02-27 00:48:16

thanks Mayor.

Anyone else have advice?

Ashaman88

2013-02-27 07:34:44

For the bonfire stuff, check out my bonfire script to see how I handle it. But pretty much you should look at your inventory change (invcount). You could do a loop to wait for it to change. I usually double the time it normally takes to do the action to account for lag (like have it loop for 6 seconds if it normally takes 3 to burn a log).

As for detecting a fire near you, it depends on which method you are using for bonfire. If you are just left clicking on the log and add to bonfire, then there isn't much you can do/need to do (just use the same area bounding as mentioned in next point). If you are rightclicking - use logs and then clicking on a fire, then you can just set the search parameter for the fire colors to be in a small box around your player.

As for staying in the same area, imo the best is SPS. If you make a custom sps map of the area, or even try out the prebuilt one - you can set a box that your player must stay in based on sps points (see example of this in my lrc script - fixposition I believe - or maybe it's in my apeatoll can't remember). But pretty much just have it check every once in awhile your sps position, if one of the points is outside of your set area box - have it sps_blindwalk back to the center. That's just my favorite method, there are others

Saint//+

2013-02-27 13:16:22

From: Ashaman88

As for staying in the same area, imo the best is SPS. If you make a custom sps map of the area, or even try out the prebuilt one - you can set a box that your player must stay in based on sps points (see example of this in my lrc script - fixposition I believe - or maybe it's in my apeatoll can't remember). But pretty much just have it check every once in awhile your sps position, if one of the points is outside of your set area box - have it sps_blindwalk back to the center. That's just my favorite method, there are others


awesome that was incredibly helpful ashaman rep+ :) btw i love your scripts i use your cooker and ape atoll agility script all the time.

what other methods are there for walking? i've been trying to use the SPS path creator from wlygon but for some reason its not working, possibly because im running simba through win on Mac OSX, i've also tried the java version by m34tcode and it doesn't want to load the maps, currently trying to figure out how make them work.

edit: just found zephyrfurys map walking tut, i think that'll answer my question.

Ashaman88

2013-02-27 13:20:40

From: Megaleech
awesome that was incredibly helpful ashaman rep+ :) btw i love your scripts i use your cooker and ape atoll agility script all the time.

what other methods are there for walking? i've been trying to use the SPS path creator from wlygon but for some reason its not working, possibly because im running simba through win on Mac OSX, i've also tried the java version by m34tcode and it doesn't want to load the maps, currently trying to figure out how make them work.

edit: just found zephyrfurys map walking tut, i think that'll answer my question.


I normally just test it out live in my scripts - Any of mine with sps walking have a sps debug mode where it just spams calls sps_getmypos and I use that to make out my paths/areas