SRL Archive - Help and Support

Proper way to use MusicLocation.Scar ?


RAM

2007-10-19 22:41:53

Hey Everyone…I'm trying to develop a fail safe for area finding using MusicLocation.Scar, while Entering and Exiting the mining guild, but I don't think I am using it correctly…and help would be much appreciated,

~RAM

Procedure AreWeDown;
begin
GetMusicLocation;
if Players[CurrentPlayer].Loc='cave background' then exit else
begin
if Players[CurrentPlayer].Loc='workshop' then
FindLadderDown;
end
FindNormalRandoms;
Respond;
end;

Procedure AreWeUp;
begin
GetMusicLocation;
if Players[CurrentPlayer].Loc='workshop' then exit else
begin
if Players[CurrentPlayer].Loc='cave background' then
FindLadderUp;
end
FindNormalRandoms;
Respond;
end;

The Claw

2007-10-19 23:59:36

I would do it like this:

if GetMusicLocation('cave background') then

Players[CurrentPlayer].Loc is a variable set by the scripter :) as in

Players[CurrentPlayer].Loc := 'here'

RAM

2007-10-20 00:09:06

Procedure AreWeDown;
begin
if GetMusicLocation('cave background') then exit else
begin
if GetMusicLocation('workshop') then
FindLadderDown;
end
FindNormalRandoms;
Respond;
end;

Procedure AreWeUp;
begin
if GetMusicLocation('workshop') then exit else
begin
if GetMusicLocation('cave background') then
FindLadderUp;
end
FindNormalRandoms;
Respond;
end;

variable Expected ?

The Claw

2007-10-20 00:20:55

ok i PMed ya

Bobarkinator

2007-10-20 00:45:47

Procedure AreWeDown;
begin
GetMusicLocation(Players[CurrentPlayer].Loc);
if Players[CurrentPlayer].Loc='cave background' then exit else
begin
if Players[CurrentPlayer].Loc='workshop' then
FindLadderDown;
end
FindNormalRandoms;
Respond;
end;

Procedure AreWeUp;
begin
GetMusicLocation(Players[CurrentPlayer].Loc);
if Players[CurrentPlayer].Loc='workshop' then exit else
begin
if Players[CurrentPlayer].Loc='cave background' then
FindLadderUp;
end
FindNormalRandoms;
Respond;
end;

You could replace the Players[CurrentPlayer].Loc to any other variable that you have defined as a string.

RAM

2007-10-20 01:13:01

Ok, i tried your way BOB….it checked location, but them terminated the script with an out of range error

[BANANA]Out Of Range in line 539 in script C:\Program Files\SCAR 3.12ccopy3\includes\SRL\SRL\misc\MusicLocation.scar[/BANANA]

[BANANA]if Pos(srl_MusicLocation.Music, LowerCase(PlayingMusic)) <> 0 then[/BANANA]

any other suggestions ?

~RAM

nielsie95

2007-10-20 04:15:55

Did you call SetupSrlMusic at the start of your script?
I added a failsafe for it in the next SRL, but for now you need to call SetupSrlMusic at the start of your script.

Remember that GetMusicLocation doesn't return the playing music but the location corresponding with the music:

srl_MusicLocation[49].Music := 'cave background'             srl_MusicLocation[49].Location := 'Dwarven Mines'

So if the music is "cave background" then GetMusicLocation will return "Dwarven Mines". If you want to make sure that a certain music is playing you should use this:

function IsMusicPlaying(Music: string): Boolean;
var
PlayingMusic: string;
begin
PlayingMusic := GetMusic;
Result := (LowerCase(Music) = LowerCase(PlayingMusic));
end;

So to integrate this in your script:


if IsMusicPlaying('cave background') then
Exit
else
begin
if IsMusicPlaying('workshop') then

{There is no need to call SetupSrlMusic at the start of your script now,
because it will not use the LocationArray.
}

Or if you want to use Locations:


if (Length(srl_MusicLocation) < 1) then
SetupSrlMusic;
if GetMusicLocation(Players[CurrentPlayer].Loc) then
begin
if LowerCase(Players[CurrentPlayer].Loc) = 'dwarven mines' then
Exit
else
if LowerCase(Players[CurrentPlayer].Loc) = 'falador, near mining guild' then
FindLadderDown;
end;

{No need to call SetupSrlMusic at the begin of your script now,
cause it will load it once at the top of this procedure:

if (Length(srl_MusicLocation) < 1) then
SetupSrlMusic;}

Wizzup?

2007-10-20 04:51:19

Or you can just use:

Function AtMine: Boolean;

Var
iX, iY: Integer;

Begin
Result := FindColoredAreaTolerance(iX, iY, 0, MMX1, MMY1, MMX2, MMY2, 100, 0);
End;

R0b0t1

2007-10-20 11:30:43

Cheap -^

n3ss3s

2007-10-20 11:51:49

Too leet for r0b0t :p jk..

Meh, now that wizzy posted, the one I use in my miner :O


Function GetWallColor(Var TPA: TPointArray; Xz1, Xz2: Integer): Integer;
Var
X, Y, I, CTS: Integer;
Begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
If (FindColorTolerance(X, Y, 6721943, MMX1, MMY1, MMX2, MMY2, 20)) Then
Begin
Result := GetColor(x, Y);
End;
FindColorsTolerance(TPA, Result, Xz1, MMY1, Xz2, MMY2, 10);
For I := 0 To GetArrayLength(TPA) - 1 Do
Begin
If (Not (Rs_OnMinimap(TPA[i].x, TPA[i].y))) Then
Begin
SetArrayLength(TPA, GetArrayLength(TPA) + 1);
TPA[GetArrayLength(TPA) - 1].x := TPA[i].x;
TPA[GetArrayLength(TPA) - 1].y := TPA[i].y;
TPA[i].x := 0;
TPA[i].y := 0;
SetArrayLength(TPA, GetArrayLength(TPA) - 1);
End;
End;
ColorToleranceSpeed(CTS);
End;

That gets the wallcolor and also gets the TPA the wall color has appeared in, and then in my InMine: Integer-

Function InMine: Integer;
Var
RTPA: TPointArray;
Begin
GetWallColor(RTPA, MMX1, MMX2);
Result := GetArrayLength(RTPA);
End;
And I have no idea why I use "InMine >= 1680" in procs instead of making the function boolean -.-

Ye back on topic we go :D

nielsie95

2007-10-20 13:06:36

Another thing:

Does GetMusic looks like this?:


function GetMusic: string;
begin
GameTab(13);
Wait(100 +Random(300));
Result := Trim(GetTextAtex(552, 240, 50, SmallChars, True, True, 0, 2, 65280,
50, False, tr_allChars));
end;

If it doesn't, please make it do so :)

Bobarkinator

2007-10-20 14:59:06

The current one does not have the wait in it.

nielsie95

2007-10-20 18:25:26

The main part is this:

GetTextAtex(552, 240 ;)

Bobarkinator

2007-10-20 18:40:30

Figured as much.

RAM

2007-10-21 11:42:26

Thanks everyone….It seems to be working very good now…Thanks for extra simplifying it for me Wiz…I was just trying to get the hang of using it for other applications, but I think yours accomplishes what I need to do the easiest :)

~RAM