Hmm, sorry… There is already a function which does that.
{*******************************************************************************
function ClickAllItems(identifier: Integer; identifiertype, option: string; waitnum: Integer; tol: TIntegerArray):Integer;
By: WT-Fakawi / Sumilion
Description: Performs "option" popupmenu action on all items
with "identifier" and "tol[0]" as color tolerance and col[1]
as contour tolerance in case bmp masks are used in inventory. (e.g. 'store all')
Returns number of performed operations. Valid identifiertypes are :
bmp, mask, color, dtm.
*******************************************************************************}
function ClickAllItems(identifier: Integer; identifiertype, option: string; waitnum: Integer; tol: TIntegerArray):Integer;
var
i, x, y, coltol, contol: Integer;
TB: Tbox;
arr:array of Integer;
IDFound: Boolean;
begin
result := 0;
case LowerCase(identifiertype) of
'bmpmask', 'bitmapmask', 'bmp mask', 'bitmap mask', 'mask':
try
begin coltol := tol[0]; contol := tol[1] end;
except
srl_Warn('ClickAllItems', 'Tol was incorrect', warn_AllVersions);
Exit;
end;
'dtm': begin end;
'bmp', 'bitmap', 'color':
try
coltol := tol[0];
except
srl_Warn('ClickAllItems', 'Tol was incorrect', warn_AllVersions);
Exit;
end;
else begin
srl_Warn('ClickAllItems', 'Invalid identifier type: ' + identifiertype, warn_AllVersions);
Exit;
end;
end;
arr :=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,
18,19,20,21,22,23,24,25,26,27,28];
for i := 1 to 28 - 4 do
Swap(arr[RandomRange(i - 1, i + 4)], arr[RandomRange(i - 1, i + 4)] );
GameTab(4);
for i := 0 to 27 do
begin
TB := InvBox(arr[i]);
if ExistsItem(arr[i]) then
begin
try
case LowerCase(identifiertype) of
'bmp', 'bitmap':
IDFound := FindBitmapSpiralTolerance(identifier, x, y, TB.x1, TB.y1, TB.x2, TB.y2, coltol);
'bmpmask', 'bitmapmask', 'bmp mask', 'bitmap mask', 'mask':
IDFound := FindBitmapMaskTolerance(identifier, x, y, TB.x1, TB.y1, TB.x2, TB.y2, coltol, contol);
'color':
IDFound := FindColorTolerance(x, y, identifier, TB.x1, TB.y1, TB.x2, TB.y2, coltol);
'dtm':
IDFound := FindDtm(identifier, x, y, TB.x1, TB.y1, TB.x2, TB.y2);
end;
if IDFound then
begin
if option <> '' then
begin
MouseItem(arr[i], False);
Wait(waitnum);
ChooseOption(option);
Inc(Result);
end
else
MouseItem(arr[i], True);
Wait(waitnum);
end;
except end;
end;
end;
end;
Thanks for trying to contribute though!