SRL Archive - SRL Suggestions

PointToInvIndex


Er1k

2012-04-29 06:38:50

This is something similar to MSTPoint/BankPoint/BankIndex conversions. I figure when we use TPA/DTM for items detection, there's no ready-to-use conversion from the found x,y to the correct inventory index to leverage MouseItem or other inv functions using an inventory index. I actually need this in my scripts quite often, so I think it might as well be a good idea to be added to the SRL includes as well.

function PointToInvIndex(p: TPoint): integer;
var i: integer;
begin
result:=0;
for i:=1 to 28 do
if PointInBox(p, InvBox(i)) then
begin
result:=i;
break;
end;
end;

NCDS

2012-04-29 07:53:50


(*
CoordsToItem
~~~~~~~~~~~~

.. code-block:: pascal

function CoordsToItem(X, Y: Integer): Integer;

Returns which Inventory slot the X and Y coords are in. If the
coords are between slots (or not in the inventory area at all) it will return 0.

.. note::

by Boreas

Example:

.. code-block:: pascal

Writeln('Item found in slot '+IntToStr(CoordsToItem(point.x, point.y)));

*)
Kind of like that? :rolleyes:

Er1k

2012-04-29 07:59:34

Thanks for the heads up. Really never noticed there's a function like that in amounts instead of inventory. Guess I totally overlooked amounts.simba. :(

Great I'll just stick to this.