Log in

View Full Version : Counting items



sm0k3
04-07-2011, 03:29 AM
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+6Fl8sljqceuoIl2lpw BRbB' +
'tptZqohLQByJhZBji1tp1UouFRMq8G7Vre1kRV2W2tTjNpS5F 2W+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
04-07-2011, 04:13 AM
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
04-07-2011, 04:35 AM
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
04-07-2011, 06:09 AM
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+6Fl8sljqceuoIl2lpw BRbB' +
'tptZqohLQByJhZBji1tp1UouFRMq8G7Vre1kRV2W2tTjNpS5F 2W+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
04-07-2011, 09:05 AM
Don't forget to free the bitmap at the end of the function! Freebitmap(snapegrass)