SRL Archive - OSR Help

Need help with first script


Roflme

2012-05-15 20:58:04

EDIT: And sorry if this is the wrong section.

So I was following YoHoJo's tutorial for making my first script.

I understand there's a thread for it Here but I posted there and had no luck so I'm hoping I can get an answer here.

So this is the script so far:
Program PowerChopper;

//{$DEFINE SMART}
{$i SRL\SRL.simba}


Const
SRLStats_Username = '';// Your SRL Stats Username
SRLStats_Password = '';// Your SRL Stats Password
BreakEvery = 120; //How Many Minutes To Break After
BreakFor = 20; //How Long To Break For
Version = '1.0';


procedure DeclarePlayer;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name := ''; //Your Runescape username
Players[0].Pass := ''; //Your Runescape password
Players[0].Active := True;
end;

Procedure StatsGuise(wat:String);
Begin
Status(wat);
Disguise(wat);
End;

Function CheckAndClick(Uptext, Option:String; X,Y:Integer; RClick:Boolean):Boolean;
Begin
MMouse(x, y, 5, 5)
If WaitUptext(UpText, 1500+Random(500)) Then
Begin
Result:=True;
GetMousePos(x, y);
If RClick Then
Begin
Mouse(x, y, 0, 0, False);
Result:= WaitOption(Option, 5000);
If Result Then FFlag(0);
End Else
Begin
Mouse(x, y, 0, 0, True);
Wait(100+Random(100));
FFlag(0);
End;
End;
End;

Procedure Antiban;
Begin
Case Random(250) Of
0: Begin StatsGuise('AntiBan') GameTab(tab_Inv) ExamineInv; GameTab(28); End;
1: Begin StatsGuise('AntiBan') RandomAngle(1); End;
2: Begin StatsGuise('AntiBan') GameTab(tab_Stats) HoverSkill('Woodcutting', False); GameTab(tab_Inv); End;
3: Begin StatsGuise('AntiBan') GameTab(tab_Stats); Wait(3000+Random(500)); GameTab(tab_Inv); End;
End;
End;

Procedure FailSafe(Reason:String);
Begin
Players[CurrentPlayer].Loc:=Reason;
Logout;
Stats_Commit;
TerminateScript;
End;

Function ChopDown:Boolean;
Var
seX, seY: Integer;
Begin
if FindObjCustom(seX, seY, ['Chop', 'Down'], [1056282, 1582114], 5) Then
begin
StatsGuise('Hooray, we found a tree');

GetMousePos(seX, seY);
Case Random(2) Of
0: Mouse(seX, seY, 5, 5, True);
1: Begin
Mouse(seX, seY, 5, 5, False);
WaitOption('Chop', 500);
End;
End;

End;
End;
begin
SetupSRL;
DeclarePlayer;
//repeat
ChopDown;
//until(false);
end.

I stopped scripting up to the point in the video where YoHoJo begins to test the script by having it cut down a few trees one at a time.

When I hit play, the mouse will go to a tree, kind of does a "twitch" (stays on the tree color, but kind of shakes a bit), and then I get this error:

New window: 14288022
[Hint] (71:10): Variable 'Result' never used at line 70
Compiled successfully in 578 ms.
SRL Compiled in 0 msec
Exception: Range check error at line 840
The following DTMs were not freed: [SRL - Lamp bitmap, 1]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap]

Can anyone help me out? :( :( :( :( :( :( :(

Abu

2012-05-16 02:39:16

Take away the capital letters in your uptexts and options

Should be:

['hop', 'own']
WaitOption('hop', 500);

Roflme

2012-05-16 05:43:08

From: abu_jwka
Take away the capital letters in your uptexts and options

Should be:

['hop', 'own']
WaitOption('hop', 500);


THANK YOU SO MUCH! I knew I made a stupid mistake somewhere :D

John

2012-05-16 06:29:27

From: Roflme
THANK YOU SO MUCH! I knew I made a stupid mistake somewhere :D

Mistakes aren't Stupid, There part of learning ;)

Rezozo

2012-05-16 06:35:40

Shizz, Wasn't first to answer…

Roflme

2012-05-27 14:53:04

So to save this section from another thread I'll just add a post here.

I continued with the script and am now have this:

Program PowerChopper;

//{$DEFINE SMART}
{$i SRL\SRL.simba}


Const
SRLStats_Username = ''; // Your SRL Stats Username
SRLStats_Password = ''; // Your SRL Stats Password
BreakEvery = 120; //How Many Minutes To Break After
BreakFor = 20; //How Long To Break For
Version = '1.0';


procedure DeclarePlayer;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name := ''; //Your Runescape username
Players[0].Pass := ''; //Your Runescape password
Players[0].Active := True;
end;

Procedure StatsGuise(wat:String);
Begin
Status(wat);
Disguise(wat);
End;

Function CheckAndClick(Uptext, Option:String; X,Y:Integer; RClick:Boolean):Boolean;
Begin
MMouse(x, y, 5, 5)
If WaitUptext(UpText, 1500+Random(500)) Then
Begin
Result:=True;
GetMousePos(x, y);
If RClick Then
Begin
Mouse(x, y, 0, 0, False);
Result:= WaitOption(Option, 5000);
If Result Then FFlag(0);
End Else
Begin
Mouse(x, y, 0, 0, True);
Wait(100+Random(100));
FFlag(0);
End;
End;
End;

Procedure Antiban;
Begin
Case Random(250) Of
0: Begin StatsGuise('AntiBan') GameTab(tab_Inv) ExamineInv; GameTab(28); End;
1: Begin StatsGuise('AntiBan') RandomAngle(1); End;
2: Begin StatsGuise('AntiBan') GameTab(tab_Stats) HoverSkill('Woodcutting', False); GameTab(tab_Inv); End;
3: Begin StatsGuise('AntiBan') GameTab(tab_Stats); Wait(3000+Random(500)); GameTab(tab_Inv); End;
End;
End;

Procedure FailSafe(Reason:String);
Begin
Players[CurrentPlayer].Loc:=Reason;
Logout;
Stats_Commit;
TerminateScript;
End;

Function ChopDown:Boolean;
Var
seX, seY, PlusOne, TreeCounter: Integer;
Begin
PlusOne:= InvCount + 1;
if FindObjCustom(seX, seY, ['hop', 'own'], [1056282, 1582114], 5) Then
begin
StatsGuise('Hooray, we found a tree');
GetMousePos(seX, seY);

Case Random(1) Of
0: Mouse(seX, seY, 5, 5, True);
1: Begin
Mouse(seX, seY, 5, 5, False);
WaitOption('hop', 500);
End;
End;

Repeat
MarkTime(TreeCounter);
AntiBan;
Wait(200);
Until (InvCount=PlusOne) Or (TimeFromMark(TreeCounter) > 7000)

End;
End;
begin
SetupSRL;
DeclarePlayer;
repeat
ChopDown;
until(false);
end.

And still got the same error!
New window: 5571526
[Hint] (72:10): Variable 'Result' never used at line 71
Compiled successfully in 578 ms.
SRL Compiled in 0 msec
Exception: Range check error at line 286
The following DTMs were not freed: [SRL - Lamp bitmap, 1]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap]


When ChopDown is like:
  //repeat
ChopDown;
//until(false)
It can click a tree successfully (I was unable to do that before). But for some reason it does not like to repeat :(

If anyone can tell me what I did now to cause this I'd highly appreciate it :D

Mufasa

2012-05-27 14:57:14

I'm going to follow his tutorials now =D Wonder if I'll arrive at the same error =3

Also, if you're still only at this stage (same as me) you should add me as a friend ^-^ we can climb through the ranks of scripting awesomeness together xD

Gucci

2012-05-27 17:53:10

Since you're not using Results in you ChopDown function you might as well make it a procedure which would also fix your problem.

Like this:

Procedure ChopDown;
Var
seX, seY, PlusOne, TreeCounter: Integer;
Begin
PlusOne:= InvCount + 1;
if FindObjCustom(seX, seY, ['hop', 'own'], [1056282, 1582114], 5) Then
begin
StatsGuise('Hooray, we found a tree');
GetMousePos(seX, seY);

Case Random(1) Of
0: Mouse(seX, seY, 5, 5, True);
1: Begin
Mouse(seX, seY, 5, 5, False);
WaitOption('hop', 500);
End;
End;

Repeat
MarkTime(TreeCounter);
AntiBan;
Wait(200);
Until (InvCount=PlusOne) Or (TimeFromMark(TreeCounter) > 7000)

End;
End;

Or if you want it as a function(not sure why) I think it would have to be:

repeat
ChopDown(x, y)
until(false)

Roflme

2012-05-28 12:02:51

From: Gucci
Since you're not using Results in you ChopDown function you might as well make it a procedure which would also fix your problem.

Like this:

Procedure ChopDown;
Var
seX, seY, PlusOne, TreeCounter: Integer;
Begin
PlusOne:= InvCount + 1;
if FindObjCustom(seX, seY, ['hop', 'own'], [1056282, 1582114], 5) Then
begin
StatsGuise('Hooray, we found a tree');
GetMousePos(seX, seY);

Case Random(1) Of
0: Mouse(seX, seY, 5, 5, True);
1: Begin
Mouse(seX, seY, 5, 5, False);
WaitOption('hop', 500);
End;
End;

Repeat
MarkTime(TreeCounter);
AntiBan;
Wait(200);
Until (InvCount=PlusOne) Or (TimeFromMark(TreeCounter) > 7000)

End;
End;

Or if you want it as a function(not sure why) I think it would have to be:

repeat
ChopDown(x, y)
until(false)

Nooby question, why do I need the (x, y) if it's a function?

I just made it a function from following the video but never understood why. I thought a procedure would have worked just as fine, which you have confirmed with that post.


From: Mufasa
I'm going to follow his tutorials now =D Wonder if I'll arrive at the same error =3

Also, if you're still only at this stage (same as me) you should add me as a friend ^-^ we can climb through the ranks of scripting awesomeness together xD



I can add you and we can chat, but until July I'm going to be extremely busy and don't even know when I'll be able to continue the tutorial. Nonetheless, I'd love to learn how to script alongside someone :D