PDA

View Full Version : ItemColors: Array of Array of Integer



n3ss3s
10-30-2007, 02:36 PM
I made this function that picks colors of items in inventory for you without any DTMs, Colors or BitMaps needed to input, all you need to give it is inventory slot(s).

Nothing big, but even more useful if you know what slot you want to autocolor.

Ignores inventory color and 65536 (black).

Umm I am not sure how good this works with a fishing net, since its pretty same coloured as the inventory background..

Btw also removes duplicate colors from the result ;)

Function InitInvTPA(Slot: Integer): TPointArray;

Var

W, H, L, CTS: Integer;

TB: TBox;

Begin

TB := InvBox(Slot);

CTS := GetColorToleranceSpeed;

ColorToleranceSpeed(2);

For W := TB.x1 To TB.x2 Do
Begin

For H := TB.y1 To TB.y2 Do
Begin

If( Not SimilarColors(GetColor(W, H), 3489352, 10))
And (Not (GetColor(W, H) = 65536)) Then
Begin

L := GetArrayLength(Result);
SetArrayLength(Result, L + 1);
Result[L] := IntToPoint(W, H);

End;

End;

End;

ColorToleranceSpeed(CTS);

End;

Function ItemColors(Slots: TIntegerArray): Array of Array of Integer;

Var

SL, F, T, S, L: Integer;

TPA: TPointArray;

Begin

If Not LoggedIn Then Exit;

SL := GetArrayLength(Slots);

If Not GetArrayLength(Slots) = 1 Then
Begin

F := 0;
T := SL - 1;

End Else
Begin

F := 0;
T := 0;
End;

For S := F To T Do
Begin

If Not ExistsItem(Slots[s]) Then Continue;

TPA := InitInvTPA(s);

L := GetArrayLength(Result);

SetArrayLength(Result, L + 1);

SetArrayLength(Result[L], GetArrayLength(TPA));

Result[L] := GetColors(TPA);

ClearSameIntegers(Result[l]);

End;
End;


EDIT: Results are in the same order as the slots you input, like [1, 2], it would return the 1st slot as the Result[0] and the 2nd as Result[1] etc..

mat_de_b
10-30-2007, 05:08 PM
Whats this useful for? only thing i can think of is finding stuff on the ground :confused:

n3ss3s
10-30-2007, 05:13 PM
You wasnt here when autocolor was invented :p

Dumpin
10-30-2007, 05:14 PM
well, I think for finding e.g pickaxe or wc axe colors, so it can see what pic you are using, wich is maybe handy for when you loose your pickaxe head

n3ss3s
10-30-2007, 05:34 PM
Thanks, yes, usage like that'd be good, though people use FindPickHeadColor.

Glad to see your chicken killer is doing good..

Dumpin
10-30-2007, 06:04 PM
hehe me to ;P

thanks ;) I might use this function once in my willow choppa :)