SRL Archive - Help

Counting items


sm0k3

2011-04-06 23:29:08



Procedure countinv;
var
i: Integer;
myBox: TBox;

begin
ItemCount:= 0;
Snapegr := BitmapFromString(24, 23, 'meJyFlDEKAkEUQ8Va8Ap7BGEbLc' +
'TCQryCl/D+nR8CISZ/ZuAXs7szj/z8zO6P1y51PBzu3zOq1lXXzwm' +
'l77ftUrX/n20h2N9CUCOIcUhQjqmtI7fney6mLe6ZqDIxuW7VGgpW' +
'pAA2hSNty0BxKCl+5IwSODsbh4nRwSmE/jAAeFT3uB9rfZmhoj8GM' +
'Tds7uaMoixyJsy6TgJb05YNYvCEgKD+6Fl8sljqceuoIl2lpwBRbB' +
'tptZqohLQByJhZBji1tp1UouFRMq8G7Vre1kRV2W2tTjNpS5F2W+E' +
'8tCUqH230k9/aKIeKmhCW/xOzfQkZdWTwCWrubf49fgFjIpI=');
for i := 1 to 28 do
begin
myBox := InvBox(i);
if CountItemsIn('inv', 'Bitmap', Snapegr, [5]);
inc(ItemCount);
SnP:= ItemCount;
End;
end;


Any ideas why it only counts one in my inventory all the time
its called everytime i pick up a Snape but it just says 1

TomTuff

2011-04-07 00:13:55

function CountSnapes: Integer;
var
BMP: Integer;
begin
BMP := BitmapFromString(0, 0, '');
Result := CountItems('dtm', BMP, [12]); //BMP tolerance goes in bracket
FreeBitmap(BMP);
end;

Bonfield

2011-04-07 00:35:02

Also remember this

if FindDTM() then
begin
Inc(ItemCount);
// whatever else you want to do
end else
Writeln('FindDTM Failed');

Because the way you have it in the first post it finds the DTM and does the counting all in one block does that make sense? I know what i mean but re-reading it, it sounds really confusing

Also is myBox ever used?

I will edit this so it makes more sense when I get home

Floor66

2011-04-07 02:09:17

Did you read the BMP tutorial I gave you on the other thread…
Anyway:

function CountInv: Integer;
var
Snapegr: Integer;
begin
Snapegr := BitmapFromString(24, 23, 'meJyFlDEKAkEUQ8Va8Ap7BGEbLc' +
'TCQryCl/D+nR8CISZ/ZuAXs7szj/z8zO6P1y51PBzu3zOq1lXXzwm' +
'l77ftUrX/n20h2N9CUCOIcUhQjqmtI7fney6mLe6ZqDIxuW7VGgpW' +
'pAA2hSNty0BxKCl+5IwSODsbh4nRwSmE/jAAeFT3uB9rfZmhoj8GM' +
'Tds7uaMoixyJsy6TgJb05YNYvCEgKD+6Fl8sljqceuoIl2lpwBRbB' +
'tptZqohLQByJhZBji1tp1UouFRMq8G7Vre1kRV2W2tTjNpS5F2W+E' +
'8tCUqH230k9/aKIeKmhCW/xOzfQkZdWTwCWrubf49fgFjIpI=');
Result := CountItemsIn('inv', 'Bitmap', Snapegr, [5]);
end;

Standards & function fixed. Please don't capitalize one bold and then leave the other lowercase :p Just make all bold worlds lowercase and use 2 spaces for indentation.

WT-Fakawi

2011-04-07 05:05:11

Don't forget to free the bitmap at the end of the function! Freebitmap(snapegrass)