Foundry
2013-10-13 16:44:26
Is there any built in function that gets the number in the top left of an inventory slot?
2013-10-13 16:44:26
2013-10-13 16:47:30
function GetAmountBox(box: TBox): integer;{=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function GetAmount(B: TBox): LongInt;
Contributors: Wanted
Description: Returns the amount of something taking into account text color within box.
Date Created: November 6th, 2011. By Wanted. RS2 Build 675.
Last Modified: March 16th, 2013. By Wanted. RS07 Build ???.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}
function GetAmount(B: TBox): LongInt;
var
TextColors: TIntegerArray;
TPA: TPointArray;
Text: string;
I: Integer;
SB: TBox;
begin
Result := 0;
TextColors := [clYellow, clWhite, 8453888];
for I := 0 to 2 do
if (FindColorExP(TPA, TextColors[I], B)) then
begin
SB := TPABounds(TPA);
Text := GetTextAtEx(SB.X1 - 1, SB.Y1 - 1, 0, StatChars, False, False, 0, 2, TextColors[I], 5, False, tr_AllChars);
Result := StrToIntDef(GetNumbers(Text), -1);
if (Result > -1) then
Result := (Result * Floor(Pow(1000, I)));
end;
end;2013-10-13 17:01:41
2013-10-13 17:27:58
2013-10-13 18:52:02
From: Olly
https://github.com/SRL/SRL-6/blob/master/lib/misc/items.simba#L172
Should work no?
2013-10-13 19:05:05
From: HardcorBoter
I tried that but it doesn't seem to be working. Always throws this back at me when I give it the right TBox for the inv slot and everything.
– WARNING: getItemAmount(): Didn't find any text color, result = 0
EDIT: Tested with stacks less than 1k(ones with yellow text) and it doesn't give an error but still returns 0.
2013-10-13 19:50:22
From: Wanted Returns
Can you play around with the code I posted and figure out how to make it work?
b.edit(-1, -1, +1, +1);to thisb.edit(-3, -3, +3, +3);makes it pick up 4 digits as opposed to the 3 it did before.
2013-10-13 19:51:58
From: HardcorBoter
I messed around with it and I think the area of the TBox it generates from the TPA is too small.
Changing thisto thisb.edit(-1, -1, +1, +1);makes it pick up 4 digits as opposed to the 3 it did before.b.edit(-3, -3, +3, +3);
2013-10-13 19:57:23
From: Wanted Returns
I'll give it a whack later when I get home..
So Old school runescape
Simba
SRL 6?
What am I working with here?
2013-10-13 20:03:48
2013-10-13 20:11:37
From: Justin
He said SRL-6 a few posts above.
2013-10-14 11:34:12
function getItemAmount(area: TBox): integer;
var
tpa: TPointArray;
b: TBox;
begin
result := 1;
if area.colorExists(ITEM_OUTLINE_WHITE) then
result := 1000;
if findColors(tpa, ITEM_TEXT_YELLOW, area) or findColors(tpa, ITEM_OUTLINE_WHITE, area) then
begin
b := tpa.getBounds();
b.edit(-3, -3, +3, +3);
result := result*strToIntDef(getTextAtEx(b, 0, 1, 1, ITEM_TEXT_YELLOW, 0, statChars, Numbers), 0);
end else
print('getItemAmount(): Didn''t find any text color, result = 0', TDebug.WARNING);
end;2013-10-14 13:32:12
From: HardcorBoter
Actually,It's not that the tpa is wrong, its not picking up certain numbers (confirmed its only 1, 2, and 4 not being detected). Does that mean the font changed?
EDIT: Did more testing and apparently it will pick up all numbers if the TBox is enlarged by 3 like in my last post. If it is left the way it is and only enlarges it by one, then it doesn't pick up those numbers. Can anyone make a function that reads the stacks with 10k+ with the white text and converts the k to 1000?
2013-10-14 15:02:15

2013-10-14 16:20:06
From: Olly
I've updated it to work with every amount (millions, etc) and it works perfectly for me.
-snip-
e: https://github.com/SRL/SRL-6/commit/331322169d94770e4d4a21907960687d0007ea8d
2013-10-14 17:18:45
From: Olly
I've updated it to work with every amount (millions, etc) and it works perfectly for me.
e: https://github.com/SRL/SRL-6/commit/331322169d94770e4d4a21907960687d0007ea8d
2013-10-14 17:22:50
From: Olly
I've updated it to work with every amount (millions, etc) and it works perfectly for me.
e: https://github.com/SRL/SRL-6/commit/331322169d94770e4d4a21907960687d0007ea8d
2013-10-14 17:24:47
From: hoodz
100k tokens?
2013-10-14 17:29:46
From: hoodz
100k tokens?