SRL Archive - OSR Help

Getting amount of a stack in inventory


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?

Wanted Returns

2013-10-13 16:47:30

https://github.com/SRL/SRL/search?q=amount&ref=cmdform

Detailed explanation coming soon ;)

Edit:

SRL-OSR???

function GetAmountBox(box: TBox): integer;

https://github.com/SRL/SRL-OSR/blob/master/SRL/core/amount.simba

#193

Edit 2: Sauce Alternative

{=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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;

Sorry I've been living under a rock for a while… maybe someone up to date with everything can tell you how to apply all of this ;)

Foundry

2013-10-13 17:01:41

Forgot to specify SRL 6. Tried getAmount and getAmountBox but those are for srl - osr I think

Olly

2013-10-13 17:27:58

https://github.com/SRL/SRL-6/blob/master/lib/misc/items.simba#L172

Should work no?

Foundry

2013-10-13 18:52:02

From: Olly
https://github.com/SRL/SRL-6/blob/master/lib/misc/items.simba#L172

Should work no?


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.

Wanted Returns

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.


Can you play around with the code I posted and figure out how to make it work?

Foundry

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?


I messed around with it and I think the area of the TBox it generates from the TPA is too small.

Changing this
b.edit(-1, -1, +1, +1);
to this
b.edit(-3, -3, +3, +3);
makes it pick up 4 digits as opposed to the 3 it did before.

Wanted Returns

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 this
b.edit(-1, -1, +1, +1);
to this
b.edit(-3, -3, +3, +3);
makes it pick up 4 digits as opposed to the 3 it did before.


I'll give it a whack later when I get home..

So Old school runescape
Simba
SRL 6?

What am I working with here?

Justin

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?


He said SRL-6 a few posts above.

Foundry

2013-10-13 20:03:48

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?

Wanted Returns

2013-10-13 20:11:37

From: Justin
He said SRL-6 a few posts above.

Just clarifying before I spend hours helping a complete stranger play a video game ;)

Foundry

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;

Would this fix the problem? I can't test it at the moment but I think it would work to output the right result for stacks above 10k.

Wanted Returns

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?


The sauce I posted does it you just have to figure out how to adapt it… I'll try when I get home

Olly

2013-10-14 15:02:15

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

Foundry

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


Thanks! I can now continue working on my fletching script :D

Wanted Returns

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

That helps me too, thanks! :) ;)

Hoodz

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


100k tokens?

Wanted Returns

2013-10-14 17:24:47

From: hoodz
100k tokens?


I'm not familiar with RS currently.. just came back… elaborate please?

I'm guessing that's impossible/insane ish?

Edit: Insane, lol ;) (look down)

Olly

2013-10-14 17:29:46

From: hoodz
100k tokens?


I actually have like 250k i think, i botted 99 via the ecto ghost thingy a few years back :p