Alright, I think I have this working pretty well. I even added a little part it that will get the exact number of the item if greater than 100k. :) I'd like a few people to test with different numbers before I commit, just to be sure. In the image below, the red box is just the inventory slot, and the yellow box is where it searches for the text. You can test with this script:
program new;
{$i srl/srl/misc/smart.scar}
{$i srl/srl.scar}
{$i srl/srl/misc/PaintSmart.scar}
function tGetAmount(Area: string; Slot: Integer): Integer;
var
textCols: TIntegerArray;
x, y, i: Integer;
b, bounds: TBox;
TPA: TPointArray;
s: String;
begin
case Lowercase(Area) of
'inv': b := InvBox(Slot);
'bank': b := BankIndexToMSBox(Slot);
'deposit box', 'dbox': b := DepositItemBox(Slot);
else
srl_Warn('GetAmount', 'Invalid GetAmount area ', warn_AllVersions);
end;
// If no item is found in the specified slot
if (not FindColor(x, y, SRL_OUTLINE_BLACK, b.x1, b.y1, b.x2, b.y2)) then
begin
srl_Warn('GetAmount', 'Item doesn''t exist in '+Capitalize(Area)+' slot '+IntToStr(Slot)+' ', warn_AllVersions);
Exit;
end;
Inc(Result);
textCols := [65535, 65278, 16777215, 8453888];
SMART_DrawBoxEx(False, b, clRed);
// Loop through all the possible text colors until one is found
for i := 0 to High(textCols) do
if (FindColor(x, y, textCols[i], b.x1, b.y1, b.x2, b.y2)) then
begin
FindColors(TPA, textCols[i], b.x1, b.y1, b.x2, b.y2);
bounds := GetTPABounds(TPA);
bounds := IntToBox(bounds.x1-2, bounds.y1-2, bounds.x2+2, bounds.y2+2);
SMART_DrawBoxEx(False, bounds, clYellow);
s := GetTextAtExWrap(bounds.x1, bounds.y1, bounds.x2, bounds.y2, 0, 1, 1, textCols[i], 0, StatChars);
Result := StrToIntDef(GetNumbers(s), 1);
// If greater than 100k, examine it to get the exact number
if ((i = 2) or (i = 3)) then
begin
MouseBox(b.x1, b.y1, b.x2, b.y2, 2);
if (WaitOption('xamine', 500)) then
Result := StrToInt(GetNumbers(GetChatBoxText(8, clBlack)));
end;
Exit;
end;
end;
var
i: Integer;
begin
Smart_Server := 152;
Smart_Members := False;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
ClearDebug;
SmartSetDebug(True);
ActivateClient;
SMART_DrawBoxEx(True, IntToBox(0, 0, 0, 0), clRed); // Clears the canvas
for i := 1 to 15 do
Writeln(IntToStr(tGetAmount('bank', i)));
//Writeln(GetNumbers(GetChatBoxText(8, clBlack)));
end.
Inventory:

Bank:

Deposit Box:
Haven't tested yet.
E: Oh, I forgot to mention that it did printed out all the right amounts. :p
E2: I've found that occasionally it won't get the right number after it right clicks an item and reads the chat text for whatever reason. Something may be wrong with that function, or GetAmount can just give an approximate result if the calculated result is less than 100k.