Results 1 to 3 of 3

Thread: PointToInvIndex

  1. #1
    Join Date
    Nov 2011
    Posts
    1,532
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default PointToInvIndex

    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.

    Simba Code:
    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;
    Current activity: Recovering from vacation
    - Nulla pars vitae vacare officio potest -
    SRL membership? Can I buy that?
    Scripts - AGS - SWF - WAR - EMS - W100S-EM
    If you need scripting help, you can pm me. Remember, if you need help you have to ask for it properly though

  2. #2
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Simba Code:
    (*
    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?

  3. #3
    Join Date
    Nov 2011
    Posts
    1,532
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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.
    Current activity: Recovering from vacation
    - Nulla pars vitae vacare officio potest -
    SRL membership? Can I buy that?
    Scripts - AGS - SWF - WAR - EMS - W100S-EM
    If you need scripting help, you can pm me. Remember, if you need help you have to ask for it properly though

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •