SRL Archive - OSR Help

Count DTM Matches?


Footy

2012-09-23 18:11:49

Is there a function for this? I've looked through the include and can't find anything. I need it to figure out how many fish were cooked, and how many were burned.

Thanks
~Footy

Nebula

2012-09-23 18:13:53

Use FindDTMs. That should store all the possible fishies as a TPA. Use Length(TPA) + 1 to determine the amount of fishies.


Footy

2012-09-23 18:16:29

Great! Thanks(again)!

:p

Brandon

2012-09-23 18:22:42

CountItemIn(……..);

It's something like that. It'll count the amount of DTM's. Or use ItemAmount(…); It'll again, count how many of a dtm is in your inventory.

Footy

2012-09-23 18:28:51

Another problem… I've made my DTM with as many points as possible so it only finds one match per fishie, but I'm still getting 244 matches with 27 fish in my inv… This is what the DTM editor looks like.

And this is my code:
procedure test;
var
thisTPA:TPointArray;
DTM, P:Integer;
begin
DTM := DTMFromString('mfgEAAHicE2JgYMhhYmDIh+JEIE4A4nIgLgHidCjOgorFAXEplJ8CxblAXATENowMDM5AbALEbkBsC8QWQGwHxO5AbIYkDlJnCMUgOUuoHEhvfHAQ0FVMFGNWBuoARiphTAAAH5sNWg==');
FindDTMs(DTM, thisTPA, MIX1, MIY1, MIX2, MIY2);
P := Length(thisTPA) + 1;
writeln(IntToStr(P));
end;

Yet the output is 244… Is there a better way to do this? I can't make any more points on the outline anymore, since I'm clicking on other points. :p

Ashaman88

2012-09-23 18:30:48

From: Footy
Another problem… I've made my DTM with as many points as possible so it only finds one match per fishie, but I'm still getting 244 matches with 27 fish in my inv… This is what the DTM editor looks like.

And this is my code:
procedure test;
var
thisTPA:TPointArray;
DTM, P:Integer;
begin
DTM := DTMFromString('mfgEAAHicE2JgYMhhYmDIh+JEIE4A4nIgLgHidCjOgorFAXEplJ8CxblAXATENowMDM5AbALEbkBsC8QWQGwHxO5AbIYkDlJnCMUgOUuoHEhvfHAQ0FVMFGNWBuoARiphTAAAH5sNWg==');
FindDTMs(DTM, thisTPA, MIX1, MIY1, MIX2, MIY2);
P := Length(thisTPA) + 1;
writeln(IntToStr(P));
end;

Yet the output is 244… Is there a better way to do this? I can't make any more points on the outline anymore, since I'm clicking on other points. :p


Do it the way Brandon suggested countitems Edit: like this to count ores in LRC script

OreCount := OreCount + CountItems('DTM',GoldDTM,[])+CountItems('DTM',CoalDTM,[]);

Footy

2012-09-23 18:38:50

From: Brandon
CountItemIn(……..);

It's something like that. It'll count the amount of DTM's. Or use ItemAmount(…); It'll again, count how many of a dtm is in your inventory.


Thanks Ashaman and Brandon, this one worked perfectly. Again, I can't rep either of you… Maybe my rep is broken. Thanks anyways! :D

J J

2012-09-24 05:19:16

You could also use the bounds of an inventory slot and search in there. If it finds one or more matches you simply increase the amount of matches by one instead of the amount of matches.


for i:=0 to 27 do
if FindDTM(blabla, InvBox(i).X1, etc.) then
inc(matches)

I'm using that in my cooking guild script for the competition but I actually ran out of variables or something so I stored them as a TBox each time. Otherwise you are using 28*4 coords :P

riwu

2012-09-24 05:37:34

From: J J
You could also use the bounds of an inventory slot and search in there. If it finds one or more matches you simply increase the amount of matches by one instead of the amount of matches.


for i:=0 to 27 do
if FindDTM(blabla, InvBox(i).X1, etc.) then
inc(matches)

I'm using that in my cooking guild script for the competition but I actually ran out of variables or something so I stored them as a TBox each time. Otherwise you are using 28*4 coords :P

Yeah that is actually how CountItems works. Mastering the SRL include can often save many lines of code ;)