SRL Archive - OSR Help

Using Cases so that Script finds Location


Paradoxium

2012-06-05 21:04:18

I was reviewing cases and understand how to use a case if the user defines the variable but how could I use cases to find my location? Something like…


If FindColorTolerence(....) then

Writeln('In Lobby');

If FindColorTolerence(...) then

Writeln('Ingame');

Le Jingle

2012-06-05 21:30:28

Well I'm not sure about about casing where you are, in order to direct where to go in your script, however I think an equivalent or better way might be to call a custom-script-specific finding function to allow (again, same concept I think as you described) to be started anywhere. For example, if your main loop calls let's say 'minerock;' the first thing in minerock; would be to verify (with findcolor, as our example) if you are near the rocks.

Just my two-sense, sorry if it's not what you are looking for, just trying to pitch other possibilities! :)

Edit: Example

Function CheckMM: Boolean;
Begin
If FindColor({stuff}) Then
Result:= True;
End;

Procedure Minerock;
Begin
If CheckMM Then
Startmining;
End;

Brandon

2012-06-05 21:44:53

This is from my own Include:


Function Location(Where: String): Boolean;
var
Dist: Integer;
P: TPoint;
begin
MakeCompass('N');
Case LowerCase(Where) Of
'cw':
Result := (FoundSymbol(2, P, Dist) OR FoundSymbol(4, P, Dist));
'naturejungle':
Result := (FoundSymbol(3, P, Dist) AND FoundSymbol(6, P, Dist));
'altar':
Result := (FoundSymbol(3, P, Dist) AND (NOT FoundSymbol(6, P, Dist)));
'ruins':
Result := FoundSymbol(7, P, Dist);
else
writeln('Invalid Location');
end;
end;


You can find out your own location by doing:


Function GetMyLocation: String;
var
I: Integer;
ListOfLocations: TStringArray;
begin
ListOfLocations:= ['cw', 'altar', 'ruins'];

For I:= 0 To High(ListOfLocations) Do
If (Location(ListOfLocations[I])) then
begin
Result:= ListOfLocations[I];
break;
end;
end;


OR you can just rewrite the function to have such a thing built in.. Something like:


type
Location = (CW, ALTAR, RUINS);


Function FoundSymbol(Where: Location): Boolean;
begin
//Iunno some crap here.. I have my own but I don't wanna publicize it yet.
end;

Function GetLocation: Location;
var
I: Integer;
Locations: TIntegerArray;
begin
Locations:= [CW, ALTAR, RUINS];

For I:= 0 To High(Locations) Do
Case Locations[I] Of
CW:
if FoundSymbol(CW) then
begin
Result:= CW;
break;
end;

ALTAR:
if FoundSymbol(ALTAR) then
begin
Result:= ALTAR;
break;
end;

RUINS:
if FoundSymbol(RUINS) then
begin
Result:= RUINS;
break;
end;
end;

begin
writeln(GetLocation);
end.

John

2012-06-06 05:18:57

From: Paradoxium
I was reviewing cases and understand how to use a case if the user defines the variable but how could I use cases to find my location? Something like…


If FindColorTolerence(....) then

Writeln('In Lobby');

If FindColorTolerence(...) then

Writeln('Ingame');


I use ObjDTM's for item finding, I suggest you try it.
As for cases, Brandon got you sorted ;)

Paradoxium

2012-06-06 09:18:48

Thanks for the replys everyone, im bout to incorportate it :D

btw John I use them too, just this script is not for RS and a basic func works just as well haha

P1ng

2012-06-06 22:53:05

Thanks for asking this! I found the replies very helpful as well :) been trying to do something like this for a little while now and it's been driving me a little bit nuts.