Tootoot222
2008-10-27 02:31:27
{*******************************************************************************
function FT(var x, y: Integer; Thing, x1, y1, x2, y2: Integer;
Tol: array of Integer; ThingType: String): Boolean;
By: Tootoot222
Description: Finds "Thing" in x1, y1, x2, y2 and stores the coords in x, y;
*******************************************************************************}
function FT(var X, Y: Integer; Thing, X1, Y1, X2, Y2: Integer;
Tol: array of Integer; ThingType: String): Boolean;
begin
case Lowercase(ThingType) of
'b', 'bmp', 'bitmap':
Result:= FindBitmapToleranceIn(Thing, X, Y, X1, Y1, X2, Y2, Tol[0]);
'c', 'clr', 'color':
Result:= FindColorTolerance(X, Y, Thing, X1, Y1, X2, Y2, Tol[0]);
'd', 'dtm':
Result:= FindDTM(Thing, X, Y, X1, Y1, X2, Y2);
'm', 'msk', 'bmpmask', 'bitmapmask', 'bmp mask', 'bitmap mask', 'mask':
Result:= FindBitmapMaskTolerance(Thing, X, Y, X1, Y1, X2, Y2, Tol[0], Tol[1]);
end;
end;
{*******************************************************************************
function FindLastInv(Thing: Integer; ThingType: String; Tol: TIntegerArray): Integer;
By: Tootoot222 / small edit by Nava2
Description: Returns the inv slot of the last occurrence of Thing in inventory
Returns 0 if Thing is not found
*******************************************************************************}
function FindLastInv(Thing: Integer; ThingType: String; Tol: TIntegerArray): Integer;
var
B: TBox;
X, Y: Integer;
begin
for Result:= 28 downto 1 do
begin
B:= InvBox(Result);
if(ExistsItem(Result)) then
if(FT(X, Y, Thing, B.X1, B.Y1, B.X2, B.Y2, Tol, ThingType)) then
Exit;
end;
Result:= 0;
end;
{*******************************************************************************
function FindFirstInv(Thing: Integer; ThingType: String; Tol: TIntegerArray): Integer;
By: Tootoot222 / small edit by Nava2
Description: Returns the inv slot of the first occurrence of Thing in inventory
Returns 0 if Thing is not found
*******************************************************************************}
function FindFirstInv(Thing: Integer; ThingType: String; Tol: TIntegerArray): Integer;
var
B: TBox;
X, Y: Integer;
begin
for Result:= 1 to 28 do
begin
B:= InvBox(Result);
if(ExistsItem(Result)) then
if(FT(X, Y, Thing, B.X1, B.Y1, B.X2, B.Y2, Tol, ThingType)) then
Exit;
end;
Result:= 0;
end;FT is a great little function i made, it finds everything ^_^
hope this is good enough for SRL :sasmokin:
EDIT: This would go into Inventory.scar