SRL Archive - OSR Help

Need Help


stu

2012-04-15 07:30:33

Hey, I have finally decided to try making my first script, after following some tutorials I have found, and have made a rough start to mine. It is a fishing script and as far as I can tell, it should just about get the job done, but I plan to improve it a lot before releasing it into the First Scripts Section.
However, when I try to run it, I get these errors:

[Hint] C:\Simba\Includes\SRL/SRL/core/mapwalk.simba(1353:3): Variable 'BOX' never used at line 1352
Compiled successfully in 765 ms.
Error: Exception: Access violation at line 101

If I comment out the Smart at the top, i only get the 'BOX' never used issue, but this means I can't even test the script without using smart.

I have never had these issues with other scripts, so it's not a problem with my java/simba, it must be my script.
Any ideas?
Thanks in advance for any help
Stu

(Also, yes i have googled/searched, I'm not one of those guys who just makes a post straight away, but nothing seems to help)

begginer

2012-04-15 07:42:58

You are getting a problem on line 101.
Please post the script here and I can c the problem. About the 'box' it's just a hint

stu

2012-04-15 07:49:17

begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP); <—101
ClearSameIntegers(arC);
arL := High(arC);

This is from using AutoColorAid so i dont see why it would have an error?

stu

2012-04-15 07:51:04

I think the error is line 101 of the Smart code, as this tab comes up when i press play

putonajonny

2012-04-15 08:35:06

From: stu
I think the error is line 101 of the Smart code, as this tab comes up when i press play


if you post the full script then we will be able to help better

Abu

2012-04-15 08:39:26

Excess violation at Line 101

stu

2012-04-15 08:41:34

ok
Like I said, it's just a start to see what does what, trying to teach myself with no prior knowledge. And once I get this working I'll rewrite all the bits that are copied, and improve it alot!
-And i'm not sure if the part at the end of my "Spotfinding" procedure will work, so could you take a look at that for me?

program Myfirstfisher;

{$DEFINE SRL5}
{$DEFINE SMART}

{$i SRL/srl.simba}
{$i SRL/SRL/misc/paintsmart.simba}

Const

//SRL Stats
SRLStats_Username = '';
SRLStats_Password = '';

//General settings
SwitchWorlds = True; //Switch worlds after break?

//Break settings
BreakIn = 235; //How long before we take a break? (minutes)
BreakFor = 15; //How long will we break for? (minutes)
Bir = 13; //Random minutes to add/subtract from how long until we break
Bfr = 7; //Random minutes to add/subjtract from break duraction

Var x, y, Tries, Tried, FishCounter: integer;

Procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := '';
Pass := '';
BoxRewards := ['XP','xp','lamp'];
LampSkill := Skill_Fishing;
Active := True;
end;
end;

Function Antiban: Boolean;
var
i: Integer;
begin
if not LoggedIn then Exit;
FindNormalRandoms;

i := Random(300);
case i of
1:
begin
RandomRClick;
Result := True;
end;
2..5:
begin
KeyDown(40);
Wait(RandomRange(500, 1100));
KeyUp(40);
Wait(RandomRange(310, 865));
SetAngle(SRL_Angle_High);
Result := True;
end;
6:
begin
HoverSkill('Fishing', False);
Result := True;
end;
7..300:
begin
Wait(RandomRange(250, 350));
Exit;
end;
end;

Wait(RandomRange(250, 350));
end;


function SpotColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.27, 0.83);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 11708319, MSX1, MSY1, MSX2, MSY2, 7);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
ColorToXYZ(arC, X, Y, Z);

if (X >= 27.52) and (X <= 46.16) and (Y >= 28.88) and (Y <= 48.80) and (Z >= 39.69) and (Z <= 55.71) then
begin
Result := arC;
Writeln('AutoColor = ' + IntToStr(arC));
Break;
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;


Procedure Spotfinding;
Begin
If Not loggedin Then
Exit;
If (not (FindObjCustom(x, y, ['Use', 'rod'], [SpotColor], 5))) Then
Wait(100+random(70));
Tried:= Tries + 1;
if(Tries = 15)Then
Begin
Logout;
Exit;
End else
if FindObjCustom(x, y, ['Use', 'rod'], [SpotColor], 5)Then
Mouse(x, y, 0, 0, True);
End;

Begin
Repeat
If InvCount=+1 Then
MarkTime(FishCounter);
Antiban;
Wait(1000);
Until(TimeFromMark(FishCounter) > 7000) or (InvFull)
End.
End.

Procedure DropFish;
Begin
If InvFull Then
DropAllExcept(1);
End;

Begin
SetupSRL;
Repeat
Spotfinding;
DropFish;
AntiBan
Until (False)
End.

NKN

2012-04-15 09:38:35

Your last Until(False) in the main loop, switch it to
Until(AllPlayersInactive)
Other people have been getting the 101 error, also.

In your global variables, it's easier to define x,y in them, but it's better if you define them in each procedure itself, to prevent any type of bugs.

Begin
Repeat
If InvCount=+1 Then
MarkTime(FishCounter);
Antiban;
Wait(1000);
Until(TimeFromMark(FishCounter) > 7000) or (InvFull)
End.
End.
You can't end the End's in periods, only the mainloop can. End them in ;
Begin
Repeat
If InvCount=+1 Then
MarkTime(FishCounter);
Antiban;
Wait(1000);
Until(TimeFromMark(FishCounter) > 7000) or (InvFull)
End;
End;

It's also better if you use the tab key, makes the script a lot easier to read.

Try to keep all the Begins,Ends,Ifs,Thens,ect all the same. If you capitalize them, capitalize all of them. If not, make them all lowercase. They all look better lowercase, anyway. ;D

Here's the script with all the spacing, to the best of my ability. (My standards aren't perfect)


program Myfirstfisher;

{$DEFINE SRL5}
{$DEFINE SMART}

{$i SRL/srl.simba}
{$i SRL/SRL/misc/paintsmart.simba}

Const

//SRL Stats
SRLStats_Username = '';
SRLStats_Password = '';

//General settings
SwitchWorlds = True; //Switch worlds after break?

//Break settings
BreakIn = 235; //How long before we take a break? (minutes)
BreakFor = 15; //How long will we break for? (minutes)
Bir = 13; //Random minutes to add/subtract from how long until we break
Bfr = 7; //Random minutes to add/subjtract from break duraction

Var
x, y, Tries, Tried, FishCounter: integer;

Procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := '';
Pass := '';
BoxRewards := ['XP','xp','lamp'];
LampSkill := Skill_Fishing;
Active := True;
end;
end;

Function Antiban: Boolean;
var
i: Integer;
begin
if not LoggedIn then Exit;
FindNormalRandoms;
i := Random(300);
case i of
1:
begin
RandomRClick;
Result := True;
end;
2..5:
begin
KeyDown(40);
Wait(RandomRange(500, 1100));
KeyUp(40);
Wait(RandomRange(310, 865));
SetAngle(SRL_Angle_High);
Result := True;
end;
6:
begin
HoverSkill('Fishing', False);
Result := True;
end;
7..300:
begin
Wait(RandomRange(250, 350));
Exit;
end;
end;

Wait(RandomRange(250, 350));
end;


function SpotColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.27, 0.83);
FindColorsSpiralTolerance(MSCX, MSCY, arP, 11708319, MSX1, MSY1, MSX2, MSY2, 7);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 27.52) and (X <= 46.16) and (Y >= 28.88) and (Y <= 48.80) and (Z >= 39.69) and (Z <= 55.71) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;


Procedure Spotfinding;
Begin
If Not loggedin Then
Exit;
If (not (FindObjCustom(x, y, ['Use', 'rod'], [SpotColor], 5))) Then
begin
Wait(100+random(70));
Tried:= Tries + 1;
end;
if(Tries = 15)Then
Begin
Logout;
Exit;
End else
if FindObjCustom(x, y, ['Use', 'rod'], [SpotColor], 5)Then
Mouse(x, y, 0, 0, True);
End;
////////////What is this?
//Begin
//Repeat
// If InvCount=+1 Then
// begin
// MarkTime(FishCounter);
// Antiban;
// Wait(1000);
// end;
//Until(TimeFromMark(FishCounter) > 7000) or (InvFull)
//End;


Procedure DropFish;
Begin
If InvFull Then
DropAllExcept(1);
End;

Begin
SetupSRL;
Repeat
Spotfinding;
DropFish;
AntiBan
Until (AllPlayersInactive)
End.

stu

2012-04-15 09:48:41

ok thanks, making these changes now
the only reason they had periods instead of semi-colons is because i tried to compile and it said "period expected", thought it was wrong though :p

edit:
like this
[Error] (149:6): period ('.') expected at line 148

also my script is spaced with tabs in simba, just didnt come out like that when i pasted it here.
What is the correct way to paste scripts?

NKN

2012-04-15 09:53:40

From: stu
ok thanks, making these changes now
the only reason they had periods instead of semi-colons is because i tried to compile and it said "period expected", thought it was wrong though :p

edit:
like this
[Error] (149:6): period ('.') expected at line 148

also my script is spaced with tabs in simba, just didnt come out like that when i pasted it here.
What is the correct way to paste scripts?

I commented all that out, because it wasn't in a procedure, which is why it said that. That might be the problem to your script.

Instead of CODE tabs, use SIMBA tabs.

If it's not in a procedure, it is the mainloop, so you need that in a procedure.

stu

2012-04-15 09:59:20

Ahh ok, thanks a lot for your help, sorry I'm such a noob.

The part where you said "What is this?" is the main bit i wanted to test, as i was fairly sure it wouldn't work so I wanted to have a play with it.
The plan was for it to start a counter every time a new fish is caught, and if that counter exceeds 7 seconds, to start spot finding again (as chances are this means the spot has moved)

NKN

2012-04-15 10:03:10

Make it a procedure.
You ran it was your mainloop, so that would be all it would do, check for fish.

Add it to one of your procedures after you defined it.

stu

2012-04-15 10:06:25

oh I see what you mean now. It is actually in my SpotFinding procedure, but the way i pasted it didn't really show that (as it doesn't show my tabbed lines)

no wait my bad it's not, changing now :P

stu

2012-04-15 10:14:56

yay, with your fixes and a few tweaks i made i am no longer getting the error at line 101 error
However i am getting a dialog box saying error starting SMART, ensure the applet page has target declaration, ill have a little search around to fix this :)

bigbutts5

2012-04-15 11:43:43

I got this error with smart, I had to un-install simba and re-install the last stable release, it also did not work with any of my ODTM's >.<

NKN

2012-04-15 21:42:15

Just start the script a few times, it'll work.