SRL Archive - OSR Help

ItemAmount


serter

2015-04-28 02:59:54

Hi,

I'm writing my first script which buys buckets of sand from a shop. ItemAmount returns the correct value for any item amounts between 0-9. When the item amount is 10 however, ItemAmount returns 0. I tried editing the tolerence for the bitmap but that would not fix it either. ItemAmount will work for other items I'm trying to buy.

The script I'm writing is using PascalScript because I used another person's script to build upon.

Also I'm having issues with the DepositScreen function, It will not work at all for any coordinates I put in. I wrote another script (A smithing script at an anvil) that gets the textTPA of the SmithingScreen when the anvil is clicked, but I couldn't get DepositScreen to work by changing the coordinates.

Any help would be great.

Flight

2015-04-28 09:26:29

Have you given AeroLib a try? You can make what's called a TItem using either a DTM or Bitmap and later directly find the amount of that 'TItem' either in your inventory or in your bank screen. Here's an examples of finding the amount of an item in the inventory, the bank and on the mainscreen (presuming you want the shop amount):

program new;
{$DEFINE SMART}
{$i AeroLib/AeroLib.Simba}

var
item_SandBucket : TItem;

procedure loadVars();
begin
with item_SandBucket do
DTM := DTMFromString('YOUR DTM STRING HERE');
end;

procedure freeGlobals();
begin
freeDTM(item_SandBucket.DTM);
end;

procedure grabItemAmounts();
var
P : TPoint;
begin
writeln('There are '+toStr(item_SandBucket.getAmount(True))+' sand buckets in the inventory');
writeln('There are '+toStr(item_SandBucket.getAmount(False))+' sand buckets in the bank');

if item_SandBucket.findIn(AREA_MS, P) then
writeln('There are '+toStr(getItemAmount(P))+' sand buckets on the mainscreen (shop interface)');
end;

begin
initAL();

loadVars();
addOnTerminate('freeGlobals');

grabItemAmounts();
end.

Simple no?

Lipcot

2015-04-28 16:57:46

you can also do this with aerolib which it'll be easier:



var
itemamount: integer;

procedure finditemamount;
begin

itemamount := getItemAmount(point(612,227)); // point where your item is
// in case you dont know where the item will be, just make a DTM, colour, BMP search and get the point that way.
end;


just an alternative to what flight said :)

Davi

2015-04-30 19:29:57

Also, I've already written a script that buys buckets of sand and soda ashe in AeroLib. You can find it here