From: Le Jingle
The above function reads the text colors of all stacks of items (not just coins) - at least that's what it should do afaik.
So, you shouldn't have to change any ``colors'' in it, as it should read them already. (if it doesn't let me know and post a .png of the non read stacked item)
As for an update to OSR, I'll look into it more and potentially yes to having this function replaced/update the current one.
-Lj
so I played around with all the options and yours worked but it did not work for values that did not have a K or M, just a simple math mistake.
if m doesnt equal 1000 or 1000000 then it must be 0 so the result s was being multiplied by 0. the edit version is below.
thanks Lj! :D :)
when s does not contain a K or M
[ATTACH=CONFIG]20737[/ATTACH]
when s does contain a K or M (notice the orginal GetAmountBox works correctly because there are no 0's in the coins but does not for the tickets which has 0's)
[ATTACH=CONFIG]20742[/ATTACH]
my edit, when s does not contain a K or M
[ATTACH=CONFIG]20739[/ATTACH]
my easy edit
function GetAmountBox2(b: TBox): Integer;
var
i, m, x, y: Integer;
s: string; // string transformed into Integer
c: TIntegerArray; // Colors of gold money text
begin
Result := 0;
if not FindColor(x, y, SRL_OUTLINE_BLACK, b.X1, b.Y1, b.X2, b.Y2) then
Exit;
c := [65535, 65278, 16777215, 8453888];
for i := 0 to high(c) do
begin
s := GetTextAtExWrap(b.X1, b.Y1, b.X2, b.Y2, 0, 5, 2, c[i], 0, StatChars);
//Multiply result by 1 if there is not a K or M (ex. 10)
if (Length(s) > 0) then
m := 1;
Break
end;
// Multiply result if there's a K or M (ex. 500K or 50M)
if (Pos('K', s) > 0) then
m := 1000
else if (Pos('M', s) > 0) then
m := 1000000;
// Replace mis-read o's or O's with zero's.
s := ReplaceRegExpr('[oO]', s, '0', True);
s := ReplaceRegExpr('[^0-9]', s, '', True); // Trim non-numbers from string
// Thus
Result := (StrToIntDef(GetNumbers(s), 1) * m);
end;
EDIT:
there for, the GetAmount(x,y) is now GetAmount2(x,y)
function GetAmount2(x, y: integer): integer;
begin
result := getAmountBox2(invBox(coordsToItem(x, y)));
end;