# Thread: Help expand my knowledge

1. SRL Junior Member
Join Date
Dec 2008
Location
Posts
51
Mentioned
0 Post(s)
Quoted
0 Post(s)

## Help expand my knowledge

I am looking for a way to make my bot go back to a default location if it wonders off, any ideas on how to do that?

2. Registered User
Join Date
Jan 2012
Posts
76
Mentioned
0 Post(s)
Quoted
0 Post(s)
For positioning recently I've been using this function that Sir Eska Eau created for me in a help thread that I changed a few tidbits on for my needs:
Simba Code:
`// *****Credit to Sir Eska Eau for crafting most of this function// * PositionTolerance :  Returns true if you are within the tolerance of the// *                        point you send in parameter. Usefull if you want to// *                        know if you are relatively close to a point.// *function PositionTolerance(posX, posY, tolx, toly: Integer): Boolean;varPosition:TPoint;begin  Position:= SPS_GetMyPos;  Result:= ((Position.x  > (posX - tolx)) and (Position.x < (posX + tolx)) and (Position.y < (posY + toly))              and (Position.y > (posY - toly)));end;`

Using an if then statement this could look something like this:

Simba Code:
`if (not(PositionTolerance({the center of the area you want to be in}, {x-tolerance for this position}, {y-tolerance for this position}) ) thenSPS_WalkToPos(Point({the center of the area you want to be in});`

So, this function basically creates a circle/square of sorts (with a radius based on your tolerances, more or less) around a center point for which the function will return true if the character is in the area and false if outside. So when your character is outside the area the if then statement above will be true and using SPS your character will walk back to the center of the area.

3. SRL Member
Join Date
Jul 2008
Location
NSW, Australia
Posts
880
Mentioned
0 Post(s)
Quoted
0 Post(s)
SPS Area's for sure it's very simple Here look at a snippet from GhettoBot

Simba Code:
`{*##################################################################################################################           Makes sure your in the right Location Before Calling Fight or Banking Procedures.##################################################################################################################*}Procedure LocationManager;Var  i, posx, posy:integer;  MyPos:tpoint;  NotInZone:boolean;begin  if(Banking=False)then  begin    if(Tries>=3)then    begin      Tries:=0;      MyPos := SPS_GetMyPos();      posx:=MyPos.x; posy:=MyPos.y;      if(Debug=True)then        writeln('My Position is ' + inttostr(posx) + ', ' + inttostr(posy));      if(not(Monster='Cow'))then      begin        if(not((Mypos.x>Bounds[0].x) and (Mypos.y>Bounds[0].y) and (Mypos.x<Bounds[1].x) and (Mypos.y<Bounds[1].y)))then          NotInZone:=true;      //Zone1      end;      if(NotInZone)then      begin        writeln('Not in zone');        notinzone:=false;        SPS_WalkPath(Monsterpath);     //Middle point if out of bounds        LocationManager;      end else`

4. Joe
Banned
Join Date
Feb 2012
Location
SRL Jail
Posts
1,321
Mentioned
0 Post(s)
Quoted
0 Post(s)
You could you use time...
like
getsystem time < (T)
if (T) = 99999 then
setupSRL;
// you walkpath here