traveler
2010-11-28 20:52:36
I made a couple of functions. First four functions return the slot numbers of the inputted ID or name. The last one returns the stacked amount of a stacked item.
{*******************************************************************************
function R_FindItemIDEx(IDs: TIntegerArray): TIntegerArray;
By: traveler
Description: Returns all the slot numbers of the IDs inputed
if Result[0] = -1, no items were found.
*******************************************************************************}
function R_FindItemIDEx(IDs: TIntegerArray): TIntegerArray;
var
I, I2, count: Integer;
begin
SetLength(Result, 28);
Count := 0;
Result[0] := -1;
for I := 1 to 28 do
begin
for I2 := 0 to High(IDs) do
if (GetItemIDAt(I) = IDs[I2]) then
begin
Result[Count] := I;
Inc(Count);
Break;
end;
end;
if(Count = 0) then
Count := 1;
SetLength(Result,Count);
end;
{*******************************************************************************
function R_FindItemID(IDs: Integer): Integer;
By: traveler
Description: Returns the first slot number of the ID inputed
if Result[0] = -1, no items were found.
*******************************************************************************}
function R_FindItemID(ID: Integer): Integer;
var
TIA: TIntegerArray;
begin
TIA := R_FindItemIDEx([ID]);
Result := TIA[0];
end;
{*******************************************************************************
function R_FindItemNameEx(Names: TStringArray): TIntegerArray;
By: traveler
Description: Returns all the slot numbers of the Names inputed
if Result[0] = -1, no items were found.
*******************************************************************************}
function R_FindItemNameEx(Names: TStringArray): TIntegerArray;
var
I, I2, Count: Integer;
begin
SetLength(Result, 28);
Count := 0;
Result[0]:= -1;
for I := 1 to 28 do
begin
for I2 := 0 to High(Names) do
if (GetItemNameAt(I) = Names[I2]) then
begin
Result[Count] := I;
Inc(Count);
Break;
end;
end;
if(Count = 0) then
Count := 1;
SetLength(Result,Count);
end;
{*******************************************************************************
function R_FindItemName(Names: string): TIntegerArray;
By: traveler
Description: Returns the first slot number of the Names inputed
if Result[0] = '', no items were found.
*******************************************************************************}
function R_FindItemName(Name: string): Integer;
var
TIA: TIntegerArray;
begin
TIA := R_FindItemNameEx([Name]);
Result := TIA[0];
end;
{*******************************************************************************
function R_StackedAmountID(ID: Integer): Integer;
By: traveler
Description: Returns the ammount of a stacked item.
if Item doesnt exist it returns a -1
*******************************************************************************}
function R_StackedAmountID(ID: Integer): Integer;
var
Slot: Integer;
begin
Slot := R_FindItemID(ID);
if ((Slot > 0) and (Slot < 29)) then
Result := GetChildComponentStack(149,0,Slot - 1)
else Result := -1;
end;