SRL Archive - OSR Help

MainLoop error?


Troll

2011-01-17 14:22:25

Ok so i have almost finshed my first scirpt, but with lots to add and change ;)
It will log in and log out and i am not sure why probly a noob error. I think its to do with the mainloop


program new;
{$DEFINE SMART}
{$i srl\srl.scar}
{$i reflection\reflection.simba}

Const
{---SMART Setup Constants---}
WORLD = 61;
MEMBERS = false;
SIGNED = true;
{---------------------------}

Procedure DeclarePlayers;
Begin
HowManyPlayers := 1;//Change this accordingly
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

With Players[0] do
Begin
Name :='user'; //Name
Pass :='pass'; //Pass
Active := True; //True if you want this player to be used
End;
End;

Procedure AntiBan(Chance:Integer);
Begin

End;

Procedure MyWait(Time:Integer);
Var Marky:Integer;
Begin
MarkTime(Marky);
Repeat
AntiBan(10000);
Wait(RandomRange(1,30));
Until ( TimeFromMark(Marky) >= Time )
End;

Function FindFishingSpotTPA:Boolean;
Var
MyTPA : TPointArray;
MyATPA : T2DPointArray;
PointT : TPoint;
x,y,i,trys : Integer;

Begin
If Not LoggedIn Then Exit;
Repeat
SetColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.34,1.18);
FindColorsSpiralTolerance(x,y,MyTPA,11576479, MSx1, MSy1, MSx2, MSy2, 4);
Inc(Trys);
Wait(RandomRange(5,95));
Until (Length(MyTPA) > 0) Or (Trys >= 12)
If Trys >= 12 Then
Begin
writeln('Not found colour exiting :(');
Result := False
Exit;
End;
MyATPA := TPAtoATPAEx(MyTPA,15,15);
For i := 0 to High(MyATPA)Do
Begin
PointT := MiddleTPA(MyATPA[i]);
writeln('looking though tpa this is the ' + IntToStr(I) +' time');
MMouse (PointT.x, PointT.y, RandomRange(-5,5), RandomRange(-5,5));
If WaitUptext('age',4500) then
Begin
SetColorToleranceSpeed(1);
writeln('found uptext');
GetMousePos(x, y);
Result := True
If Random(3000) = 5 Then
Begin
writeln('right clciking');
Mouse(x, y, 0, 0, False);
WaitOption('ag',4500);
End Else Begin
Mouse(x,y,0,0,True);
writeln('left clicking');
End;
Exit;
End;
writeln('did not click this was number ' + IntToStr(I) + ' in the array of tpa ');
End;
Wait(RandomRange(250,999));
End; {
Function FindFishingSpotRef:Boolean;
Function WalkToNoteGuyTPA:Boolean; }
Function WalkTo(Who:String):Boolean;//Spot/Guy
Var Path:TTileArray;
Begin
Case Lowercase(Who) Of
'guy' :Path := [ Tile(2924, 3175), Tile(2914, 3163), Tile(2900, 3156),
Tile(2886, 3145), Tile(2874, 3150), Tile(2860, 3149),
Tile(2851, 3145)
];
'spot' :Path := [ Tile(2854, 3144), Tile(2866, 3152), Tile(2880, 3162),
Tile(2895, 3162), Tile(2911, 3166), Tile(2924, 3175)
];
End;
Result := WalkPath(Path)
End;

Function CheckIfFishingColor:Boolean;
Var InvAmount,MarkingTime:Integer;
Begin
InvAmount := InvCount
MarkTime(MarkingTime);
writeln(' entering color fishing loop, this may result in you doing nothing for upto 4 mins ');
Repeat
If InvCount > InvAmount Then
Begin
writeln('More items in inv result true and exiting');
Result := True
Exit;
End;
If TimeFromMark(Markingtime) >= 60000*4 Then
Begin
writeln(' It has been over 4 mins we are now exiting and returning false');
Result := False
Exit;
End;
MyWait(RandomRange(500,5000));
Until(False)
End;

Function CheckIfFishingRef:Boolean;
Begin
If GetAnimation > 0 Then
Begin
Result := True
writeln('Reflection says we are doing something resulting true');
End Else Begin
Result := False
writeln('Reflection says we are not fishing');
End;
End;
{
Function TurnFishToNotesTPA:Boolean;
Var x,y,i:Integer;
MyTPA:TPointArray;
PointT:TPoint;
Begin

SetColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.8,0.18);
FindColorsSpiralTolerance(x,y,MyTPA,3421238, MSx1, MSy1, MSx2, MSy2, 3);

If Length(MyTPA) <= 2 Then
Begin
writeln('Not found the guy');
Result := False
Exit;
End;

While IsMoving DO
Begin
MyWait(500);
End;
Wait(RandomRange(100,300));

For I := 0 To High(MyTPA) Do
Begin
PointT := MyTPA[i]
MMouse(PointT.x,PointT.y,4,4);
If Not WaitUptext('es',RandomRange(3000,6000)) Then
Begin
writeln('COuld not find uptext on note guy');
Result := False
Exit;
End;
GetMousePos(x,y);
Mouse(x,y,0,0,False);
If Not WaitOption('chan',RandomRange(2000,5000)) Then
Begin
writeln('Could not find the option to exchange ');
Result := False
Exit;
End;
Result := True
If InvFull Then
Result := False
End;
End;
}

Function FindAndClickStilesRef:Boolean;
Var Stiles:TNPC;
x,y:Integer;
Begin
If FindNPC(11267,Stiles) Then
Begin
MMouse(Stiles.Pixel.x,Stiles.Pixel.y,3,3);
If WaitUptext('ile',3000+Random(300)) Then
Begin
GetMousePos(x,y);
Mouse(x,y,0,0,False);
If Not WaitOption('xch',RandomRange(1000,3000)) Then
Begin
writeln('Not found Option');
exit;
End;
Result := true
End Else writeln('No uptext :(');
End Else writeln('no npc found');
End;




//Procedure Proggy;
Procedure StartUp;
Begin
Smart_Members := MEMBERS;
Smart_Server := WORLD;
Smart_Signed := SIGNED;
SetupSRL;
SetUpReflectionEx(true);
DeclarePlayers;
LoginPlayer;
End;
//Procedure SmartDebug; //????? Maybe later

Procedure StopPlayer;
Begin
If LoggedIn THen Logout;
NextPlayer(False);
LogInPlayer;
End;

Procedure MainLoop;
Var time:Integer;
Begin
Repeat
If Not LoggedIn Then Exit;
If Not Invfull Then
Repeat
If Not CheckIfFishingRef Or CheckIfFishingColor Then
If FindFishingSpotTPA Then
Begin
MarkTime(time);
Repeat
If Not CheckIfFishingColor Then Break;
If Not CheckIfFishingRef Then Break;
If TimeFromMark(Time) > 1200000 Then Break;
MyWait(RandomRange(50,1000));
Until(False);
End;
If InvFull Then
Begin
If Not WalkTo('Guy') Then
StopPlayer;
If Not FindAndClickStilesRef Then
Begin
//CHeck where we are
//walk web walk somewhere?
StopPlayer;
//stop is not worked after trying again
End;
If Not WalkTo('spot') Then
StopPlayer;
End;
Until(Not LoggedIn {Or player loads(Not sure how to set :('});
NextPlayer(False);
Until(AllPlayersInactive);
End;

Begin
StartUp;
MainLoop;
End.
and the debug

SMART Initialized.
Loaded: Server 61, Members: False, Signed: True, Super Detail: False.
Welcome to Runescape.
My user name
NextPlayer
SwitchToPlayer(PlayerNo: 0, Active: False);
Player is not Active...
All players not active!
Successfully executed.

Thanks


P.S. its all over the place as bits come from failed attempts at stuff :fiery:

Troll

2011-01-18 10:36:22

Sorry for the bump, but anyone please i still cant find the problem :(

**BANNED The Man

2011-01-18 14:34:37

It's here:
If Not CheckIfFishingColor Then Break;
I think…
What that is doing is if it cant checkiffishing then it will break out of the loop causing your player to go false.

-Boom

Troll

2011-01-18 15:25:49

No dont think so unless your looking somewhere im not. As its a small repeat look that is only called after finding a spot

Thanks tho

**BANNED The Man

2011-01-18 15:38:35

Do some debugging then?

Procedure MainLoop;
Var time:Integer;
Begin
Repeat
If Not LoggedIn Then Exit;
If Not Invfull Then
Repeat
If Not CheckIfFishingRef Or CheckIfFishingColor Then
If FindFishingSpotTPA Then
Begin
Writeln('FoundFishingSpotTPA');
MarkTime(time);
Repeat
If Not CheckIfFishingColor Then Break;
If Not CheckIfFishingRef Then Break;
If TimeFromMark(Time) > 1200000 Then Break;
MyWait(RandomRange(50,1000));
Until(False);
End;
If InvFull Then
Begin
If Not WalkTo('Guy') Then begin
Writeln('Couldnt walkto Guy');
StopPlayer;
end;
If Not FindAndClickStilesRef Then
Begin
writeln('couldnt FindAndClickStilesRef');
//CHeck where we are
//walk web walk somewhere?
StopPlayer;
//stop is not worked after trying again
End;
If Not WalkTo('spot') Then begin
writeln'couldnt walkto spot');
StopPlayer;
End;
Until(Not LoggedIn {Or player loads(Not sure how to set :('});
NextPlayer(False);
Until(AllPlayersInactive);
End;

See what that returns

Troll

2011-01-18 15:51:37

Ok thanks :)

KingKong

2011-01-18 23:01:14

Did you manage to find out where the problem is with your script?

Troll

2011-01-19 02:29:49

No not yet :(

KingKong

2011-01-19 03:42:57

I ran it and it actuall fishes for me but doesn't find stiles although it walks near him, did you actually run it at karamja or somwhere else? Also as trivial as it may sound, did you set your display settings correctly?

Troll

2011-01-19 10:44:01

Lol yes the sceen is right, i did get the colors myself :p
Also i just saw that in my scirpt im only runing the stiles bit, so thats why, god im silly

Thanks for testing it though :)

And yh i ran it at karamja it is where i made it ;)