Richard
2012-01-11 20:48:52
For inventory.simba. Two basic functions that just return the inventory slot(s) of the given DTM. Could easily be adapted for BMPs. Not exactly complicated, but was making them for a script, though it could be useful to others:
GetInvSlotsDTM:
GetInvSlotDTM
GetInvSlotsDTM:
(*
GetInvSlotsDTM
~~~~~~~~~~~~~
.. code-block:: pascal
function GetInvSlotsDTM(DTM: Integer): TIntegerArray;
Returns the inventory slots of all occurances of the given DTM.
Returns nothing if not found.
.. note::
by Richard
Example:
.. code-block:: pascal
TIA := GetInvSlotsDTM(OreDTM) then
If Length(TIA) > 0
MMouseItem(TIA[1]);
*)
function GetInvSlotsDTM(DTM: Integer): TIntegerArray;
var
i: Integer;
TPA: TPointArray;
begin
If not FindDTMs(DTM, TPA, MIX1, MIY1, MIX2, MIY2) then
Exit;
SetArrayLength(Result, High(TPA) + 1);
For i := 0 to High(TPA) do
Result[i] := CoordsToItem(TPA[i].x, TPA[i].y);
ClearSameIntegers(Result);
end;GetInvSlotDTM
(*
GetInvSlotDTM
~~~~~~~~~~~~~
.. code-block:: pascal
function GetInvSlotDTM(DTM: Integer): Integer;
Returns the inventory slot of the given DTM.
Returns nothing if not found.
.. note::
by Richard
Example:
.. code-block:: pascal
i := GetInvSlotDTM(OreDTM);
MMouseItem(i);
*)
function GetInvSlotDTM(DTM: Integer): Integer;
var
x,y: Integer;
begin
If not FindDTM(DTM, x, y, MIX1, MIY1, MIX2, MIY2) then
Exit;
Result := CoordsToItem(x, y);
end;