Results 1 to 4 of 4

Thread: Few questions about Arrays and Dismantling them.

  1. #1
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Few questions about Arrays and Dismantling them.

    First of all, is there a way to use a ExistItem(I) or whatever the command is, and return the inventory spots that are occupied into an Array of Integer?

    If it's possible, how would I go about taking it apart, so I could fit it into this procedure?

    SCAR Code:
    procedure DropAllExcept(A : Array of Integer);
    var
      i: Integer;
    begin
    For I:=1 To 28 Do
        if not(InIntArray(a, i)) then
          DropItem(i);
    end;

    Thanks, Sandstorm.

  2. #2
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    I think what you want would be a modified form of the InvCount function. You can find that in Inventory.scar in the core folder of SRL. Anyway, what it does is performs ExistsItem(i) for each of your inventory slots, then tells you how many have items in them. What you'll want it to do is, instead of simply counting, have it store the position of the item in an array.

  3. #3
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    SCAR Code:
    function GetInventorySlots: TIntegerArray;
    var
      Slot: Integer;
    begin
      for Slot := 0 to 27 do
        if (ExistsItem(Slot + 1)) then
        begin
          SetArrayLength(Result, Length(Result) + 1);
          Result[Slot] := Slot + 1;
        end;
    end;

    I think that should get you all of the inventory slots that have items in there, but you should probably test it out to be sure.
    :-)

  4. #4
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ok, thanks Method. That works perfectly. Except it doesn't do quite what I want it to do. I want it to take stock of the inventory at the start of the script, then drop everything except that. I'm gonna see if I can tweak that right now, actually.

    Edit: Alright, I got it working the way I wanted to. Thanks for the help Method .

    You to Senrath.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Arrays, stuck on arrays
    By Camaro' in forum OSR Help
    Replies: 1
    Last Post: 03-08-2008, 02:02 AM
  2. Need Help With Arrays
    By papenco in forum OSR Help
    Replies: 16
    Last Post: 11-28-2007, 03:56 AM
  3. Help with Arrays
    By kooldude in forum OSR Help
    Replies: 16
    Last Post: 06-15-2007, 05:36 AM

Posting Permissions

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