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..
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..