Hi all,
Created this to learn a bit about arrays and for..to..do.
Let me know what you think and improvements i could make on it!
Simba Code:{*
GetBlackCountAll
~~~~~~~~~~~~
.. code-block:: AeroLib
GetBlackCountAll(MyArray: TIntegerArray; Count: Integer): Integer;
Checks the nominated TIntegerArray and reports back with the amount of black pixels found, storing it in an integer.
.. note::
by Dan the man
Example:
//Counts how many items in the inventory have 68 black pixels in them and saves it to an integer.
BlackitemCount := (GetBlackCountAll(TItem.getslots(), 68));
*}
function GetBlackCountAll(MyArray: TIntegerArray; Count: Integer): Integer;
var
i: integer;
ItemCount: integer;
TempBox: Tbox;
BlackPixelCol: TColEx;
begin
BlackPixelCol.create(65536, 0);
ItemCount := 0;
Setlength(MyArray, 28);
for i := Low(MyArray) to High(MyArray) do
if ((MyArray[i]) > 0) then
begin
TempBox := (InvBox(MyArray[i]));
if (BlackPixelCol.count(TempBox) = Count) then
Inc(ItemCount);
end;
Result := ItemCount;
end;
@Flight