SRL Archive - SRL Archives

Amount.Scar GetAmount(); fix


NCDS

2010-06-23 16:59:28

I had to update the Color for the text and since the color seems to now be static I changed 'Col' from a TIntegerArray to an Integer; Seems like the color should be a constant anyways?

I've tested multiple times and it's worked every time.

Old version:

{*******************************************************************************
function GetAmount(ItemX, ItemY: Integer): Integer;
By: Zeph, N1ke & Narcle
Description: Returns the amount of an item at coordinates (ItemX, ItemY).
Returns approximate values for 'K' and 'M'.
*******************************************************************************}
function GetAmount(ItemX, ItemY: Integer): Integer;
var
Col: TIntegerArray;
X, Y, I: Integer;
B: TBox;
TPA: TPointArray;
S: String;
begin
Result := 0;
If Not FindColor(X, Y, srl_outline_black, ItemX-30, ItemY-30, ItemX+30, ItemY+30)then
Exit;
Inc(Result);
Col := [65535, 16777215, 8453888];
For I:=0 to 2 do
If FindColor(X, Y, Col[I], ItemX-22, ItemY-22, ItemX+22, ItemY+22)then
begin
FindColors(TPA, Col[i], ItemX-22, ItemY-22, ItemX+22, ItemY+22);
B := GetTPABounds(TPA);
S := Trim(GetTextAtEx(B.X1-1, B.Y1-1, 0, StatChars, False, False, 0, 1, Col[I], 5, True, tr_AllChars));
Result := StrToIntDef(GetNumbers(S), 1);
Case I of
1: Result := Result * 1000;
2: Result := Result * 1000000;
end;
Exit;
end;
end;
Fix:

{*******************************************************************************
function GetAmount(ItemX, ItemY: Integer): Integer;
By: Zeph, N1ke & Narcle
Description: Returns the amount of an item at coordinates (ItemX, ItemY).
Returns approximate values for 'K' and 'M'.
*******************************************************************************}
function GetAmount(ItemX, ItemY: Integer): Integer;
var
Col: TIntegerArray;
X, Y, I: Integer;
B: TBox;
TPA: TPointArray;
S: String;
begin
Result := 0;
If Not FindColor(X, Y, srl_outline_black, ItemX-30, ItemY-30, ItemX+30, ItemY+30)then
Exit;
Inc(Result);
Col := [65535, 65278, 16777215, 8453888];
For I:=0 to 3 do
If FindColor(X, Y, Col[i], ItemX-22, ItemY-22, ItemX+22, ItemY+22)then
begin
FindColors(TPA, Col[i], ItemX-22, ItemY-22, ItemX+22, ItemY+22);
B := GetTPABounds(TPA);
S := Trim(GetTextAtEx(B.X1-1, B.Y1-1, 0, StatChars, False, False, 0, 1, Col[i], 5, True, tr_AllChars));
Result := StrToIntDef(GetNumbers(S), 1);
Case I of
1: Result := Result * 1000;
2: Result := Result * 1000000;
end;
Exit;
end;
end;

i luffs yeww

2010-06-23 17:04:33

It should still have three colors, as there are three different colors for gold pieces, aren't there?

NCDS

2010-06-23 17:06:14

From: i luffs yeww
It should still have three colors, as there are three different colors for gold pieces, aren't there?


There is a different function for finding Coins. ;)

You were right, some of them do use the other color. I changed it accordingly.

Frement

2010-06-23 17:09:29

From: NCDS
There is a different function for finding Coins. ;)


No, there are yellow, white, green.

NCDS

2010-06-23 17:19:05

Added back the other colors. I guess the one yellow just needed to be updated.

Seems like these colors should be constants..

Narcle

2010-06-23 17:19:51

Those 3 colors are there to determine the correct modifier. 1st color is standard yellow, 2nd is color for k, 3rd is for m as they all have different colors once you are at those amounts…

And I actually have a better version for Simba, as sometimes when you GetAmount in the inventory it'll read the item text next to it.

NCDS

2010-06-23 17:22:58

From: Narcle
Those 3 colors are there to determine the correct modifier. 1st color is standard yellow, 2nd is color for k, 3rd is for m as they all have different colors once you are at those amounts…

And I actually have a better version for Simba, as sometimes when you GetAmount in the inventory it'll read the item text next to it.


Ah, well I tested every color except the green and they all work now so I guess I'll just let you do your Dev thing.

Narcle

2010-06-23 17:26:27

From: NCDS
Ah, well I tested every color except the green and they all work now so I guess I'll just let you do your Dev thing.


I was thinking of just adding defines for it in SRL so it uses the better method for Simba. There are like 3 other functions I should do this too.

Where does it use the other color? I haven't had problems with it using it for banking or inventory.

Frement

2010-06-23 17:28:01

Worked fine.

Compiled succesfully in 546 ms.
SRL Compiled in 16 msec
12000000
Successfully executed.
Compiled succesfully in 546 ms.
SRL Compiled in 16 msec
500000
Successfully executed.
Compiled succesfully in 546 ms.
SRL Compiled in 16 msec
5
Successfully executed.

Narcle

2010-06-23 17:37:13

From: Frement
Worked fine.

Compiled succesfully in 546 ms.
SRL Compiled in 16 msec
12000000
Successfully executed.
Compiled succesfully in 546 ms.
SRL Compiled in 16 msec
500000
Successfully executed.
Compiled succesfully in 546 ms.
SRL Compiled in 16 msec
5
Successfully executed.


In your inventory put something with an amount of 4 letters then right next to it one with 5 letters.

like

3423 63345

Frement

2010-06-23 17:45:36

Worked still fine.

Compiled succesfully in 546 ms.
SRL Compiled in 16 msec
9005
Successfully executed.
Compiled succesfully in 546 ms.
SRL Compiled in 0 msec
67852
Successfully executed.

EDIT: My yellow is: 65535

i luffs yeww

2010-06-23 20:21:05

^ wat.

I thought 65535 was black?

Narcle

2010-06-23 20:27:07

From: i luffs yeww
^ wat.

I thought 65535 was black?


65536 is black.

MylesMadness

2010-06-23 20:27:24

From: i luffs yeww
^ wat.

I thought 65535 was black?
program new;
var
R, G, B:Integer;
begin
ColorToRGB(65535, R, G, B);
Writeln(R);
Writeln(G);
Writeln(B);
end.
Compiled succesfully in 16 ms.
255
255
0
Successfully executed.
That ends up being FFFF00, and http://www.colorcombos.com/FFFF00-hex-color

Wanted

2010-06-23 23:06:49

I am deeply confused by this thread.

NCDS

2010-06-23 23:10:36

From: IceFire908
I am deeply confused by this thread.


The yellow text color needed to be updated, so I did. Narcle apparently has a better way of doing it in SRL5 though. Not sure what that leaves us with now though..

Wanted

2010-06-23 23:13:12

Just the yellow?

Edit: It appears yellow is fine?

Frement

2010-06-23 23:47:31

From: IceFire908
Just the yellow?

Edit: It appears yellow is fine?


Yeah, worked for me too.

NCDS

2010-06-24 00:06:29

From: IceFire908
Just the yellow?

Edit: It appears yellow is fine?


From: Frement
Yeah, worked for me too.


There's 2 different shades of yellow. Try it on multiple different items.

Equipped arrows wouldn't work before I fixed I know that, but Nature runes would. They were 2 different shades though.

i luffs yeww

2010-06-24 03:27:52

From: Narcle
65536 is black.


Wow. That is very misleading. :p Thanks.

(Thanks for the explanation to you, too, Myles.

Narcle

2010-06-24 11:45:30

From: NCDS
There's 2 different shades of yellow. Try it on multiple different items.

Equipped arrows wouldn't work before I fixed I know that, but Nature runes would. They were 2 different shades though.


Its probably just the equipped arrow spot then that has a different shade now. Is there any other places you know of?

(Good to know that, I'll add the color for arrows in)

Edit:
yeah 65278 is the equipped arrow amount color, not surprised as its a different interface from the bank/inv

NCDS

2010-06-24 16:53:36

From: Narcle
Its probably just the equipped arrow spot then that has a different shade now. Is there any other places you know of?

(Good to know that, I'll add the color for arrows in)

Edit:
yeah 65278 is the equipped arrow amount color, not surprised as its a different interface from the bank/inv


So with the color I added it should detect all now then, correct?