SRL Archive - OSR Help

How Do You Regions In SPS-OSR?


hedfun2

2013-06-03 16:22:03

I want to be able to create a region such as the bank or the area that i'm working in and tell the bot to do something when in that area. For example, say I want the bot bank when it is in the bank. Or I would want the bot to perform a certain procedure once entered a specific region. How would I create these regions?

Haxz

2013-06-03 16:39:24

You mean something like this?


Function InsideArea(x1, y1, x2, y2: Integer): Boolean;
var
P: TPoint;
Box: TBox;
begin
P := SPS_GetMyPos;
Box := IntToBox(x1, y1, x2, y2);
if PointInBox(P, Box) then
begin
Result := True;
end;
end;

Kevin

2013-06-03 16:48:19

There are any number of methods you could go about this. The easiest methods would be to use an SPS map and check if you're in a dedicated area of the map that you would define as the map, or an objdtm node where you can determine if you're in an area using that. However, I think the best way to be to script procedurally:

That means you would setup your script so you would walk to the bank, and then bank when your walking procedure is done. That way you don't have to check your current location every single time you want to do something and instead just know where you are because of the previous method that ran.

repeat
A;
B;
C;
D;
E;
until(not loggedIn);
instead of what you're suggesting:

repeat
if(in area A)then A;
if(in area B)then B;
if(in area C)then C;
if(in area D)then D;
if(in area E)then E;
until(not loggedIn);

hedfun2

2013-06-03 17:22:33

I tried your method Haxz and it works great! Thanks!

Haxz

2013-06-03 18:47:08

From: hedfun2
I tried your method Haxz and it works great! Thanks!


Make sure you script some failsafe because sometimes SPS returns wrong coordinates when map has too much white dots, or is returning 1-, -1. So make sure your script don't get stuck somewhere you're using the function.