SRL Archive - Discussions and Debates

Problem with Count


grindisbest

2007-06-06 23:36:17

I use this Amount('inv',1) in one of my scripts to count the coins. Since they changed the color of gp numbers I noticed somethings, like 1/100 it doesn't get it right and misses the first number. Even when I'm counting under 100k.

Boreas

2007-06-06 23:42:49

Take a screenie of what gives you a problem and I'll take a look. I may leave it to masq to do :p

program New;
{.include srl/srl.scar}
var BankBmp,w,h:integer;
begin
//+3 for paint
GetClientDimensions(w,h);
BankBmp:=BitmapfromString(w,h,'');
CopyClientToBitmap(BankBmp,3,3,w+3,h+3);
SaveBitmap(BankBmp,apppath+'perfectscreenie2.bmp');
end.
Run that and upload pic that will be in scar folder please.

masquerader

2007-06-06 23:47:40

misses the first number?
that sounds like a problem

yeah, take some screenshots, definately

also, try replacing this in amount.scar:

{*******************************************************************************
function GetAmount(itemx, itemy: Integer): Integer;
By: masquerader || Improved by Freddy1990 ||Updated June 4 2007 by Boreas
Description: Returns the ammount of an item at a certain position.
*******************************************************************************}

function GetAmount(itemx, itemy: Integer): Integer;
//uses font cropped to work with "Opponent's Offer"
//coords are same as ones from istextinarea, but
//you probably shouldnt use this function directly (others use it)
//'K' and 'M' work (for approx values)
//non-stackable =1
//blank = 0
var
amountstr: string;
tempx, tempy, color: Integer;
begin
if findcolor(tempx, tempy, 65535, itemx, itemy, itemx + 10, itemy + 10) then
color := 65535;
if color = 0 then
if findcolor(tempx, tempy, 16777215, itemx, itemy, itemx + 10, itemy + 10) then
color := 16777215;
if color = 0 then
if findcolor(tempx, tempy, 8453888, itemx, itemy, itemx + 10, itemy + 10) then
color := 8453888;
amountstr := Trim(GetTextAtEx(itemx + 1, itemy + 3, 0, tradeChars, False, False,
0, 2, color, 5, True, tr_AlphaNumericChars));
if (Length(amountstr) > 0) then
begin
if (Pos('K', amountstr) > 0) then
begin
Delete(amountstr, Length(amountstr), Length(amountstr));
Result := StrToInt(amountstr) * 1000;
end else
if (Pos('M', amountstr) > 0) then
begin
Delete(amountstr, Length(amountstr), Length(amountstr));
Result := StrToInt(amountstr) * 1000000;
end else
Result := StrToInt(amountstr);
end else
if (FindColor(tempx, tempy, 65536, itemx, itemy, itemx + 30, itemy + 30)) then
Result := 1;
end;

grindisbest

2007-06-08 08:44:25

But, it's very rarely so I don't really get the chance to get a screen shot. I'll try you fix though and see how I go. In 30 hours a running my eye of newt buyer 3 players fell to it.

grindisbest

2007-06-08 10:06:53

Ok, I'm using CoinAmount('inv'); and when I have 5gp in the first inventory slot it picks it up as 0. It's the same with a few others like 6, 7, 8 and so on for awhile. Also that function you posted, stops it working for me altogether and it just returns 1 no matter what.

Boreas

2007-06-08 10:08:30

Run the script posted above and upload resulting pic please.

masquerader

2007-06-08 21:49:57

i think that the current coinamount uses a bitmap to find the money

i thought it was pretty good, but it might not work with specific amounts because the graphic changes and such

you are welcome to post a DTM or something that you think will find any coin stack better

grindisbest

2007-06-08 23:56:45


It wouldn't find this using coinamount

Boreas

2007-06-09 02:38:33

Kk for now, get that updated GetAmount, and use Amount.

grindisbest

2007-06-09 03:31:31

that update didn't work for me, it just always returned 1.

Boreas

2007-06-09 10:12:35

You don't use GetAmount, you use Amount. Amount uses GetAmount.

grindisbest

2007-06-09 16:43:41

Yeah that's what I do