SRL Archive - SRL Suggestions

CountDotsIn


bugger0001

2010-06-16 14:37:23

I was writing a woodcutting function where I needed to check if there are other players near me. I thought that I could take advantage of the MiniMap functions we have in MapWalk.scar and then noticed, that we have a
function CountDots(WhatDot: String): integer;

But from where I was standing I didn't want to scan the whole MiniMap. Therefore I wrote this little thing:
function CountDotsIn(WhatDot: String; xs, ys, xe, ye: Integer): integer;
begin
Result := Length(GetMinimapDotsIn(WhatDot, xs, ys, xe, ye));
end;

Pretty much does the same thing as CountDots, but lets you decide the area from where you want to count the Dots. I think that if we have CountDots then why not have a CountDotsIn aswell :p

Sir R. M8gic1an

2010-06-16 15:03:27

Sounds good.

Just make CountDotsEx and wrap CountDots.

~RM

bugger0001

2010-06-16 15:23:03

Do you mean like this?
function CountDotsEx(WhatDot: String; xs, ys, xe, ye: Integer): integer;
begin
Result := Length(GetMinimapDotsIn(WhatDot, xs, ys, xe, ye));
end;

function CountDots(WhatDot: String): integer;
begin
Result := CountDotsEx(WhatDot: String, MMX1, MMY1, MMX2, MMY2);
end;

Wouldn't it be a bit of an overkill to convert CountDots to the above? I mean, it wouldn't shorten the code nor change the way it works.

Sir R. M8gic1an

2010-06-16 16:36:55

Quite honestly I dislike one line functions, and so I wouldn't have had CountDotsin the first place, but the way I suggested makes logical sense, due to 'CountDots' being a "generalization of "CountDotsIn". Anyway, I'm on ubuntu atm and (so) can't commit yet, but if it hasn't been done by the time I switch to windows I'll do it.

~RM

bugger0001

2010-06-16 16:50:02

From: Rasta Magician
…but the way I suggested makes logical sense, due to 'CountDots' being a "generalization of "CountDotsIn"…


Ok, makes sense.

marpis

2010-06-17 07:16:10

Why not just let the user use Length() and GetMinimapDotsIn

Length(GetMinimapDotsIn('player', MMX1, MMY1, MMCX, MMCY));

bugger0001

2010-06-17 15:46:22

It's more convenient to type a:=GetDotsEx(blah);
than a:=Length(GetMinimapDotsIn(blah));

Pure lazyness, though we already have CountDots in SRL, that's the only reason I proposed CountDotsIn