Results 1 to 5 of 5

Thread: Items, examples..

  1. #1
    Join Date
    Feb 2013
    Location
    Rimmington
    Posts
    319
    Mentioned
    33 Post(s)
    Quoted
    183 Post(s)

    Default Grounditems by item name, examples..

    If you haven't read about items, then please, go here first

    With the latest release of itemDefs we no longer have to work with ID's.
    Everytime you run a function regarding items, itemDefs will be loaded and stored.
    Accessing your item names can be done by Items.Name!

    As TReflectGroundItem is an extension to TReflectItem there's two new variable that can be accessed,
    • Tile: TTile
    • Quantity: Integer


    Tile obviously showing us where the item is located.
    Quantity for the amount. (None stackable items = 1).

    Simba Code:
    program TutorialGroundItems;
    {$DEFINE SMART}
    {$i Reflection/Reflection.simba}


    {
    All grounditems functions have a parameter for the distance it'll search.
    The less the better, as you'll almost never try to find a item outside your
    minimap range.
    }

    const
      GroundItems_Dist = 20;

    {
    Drops are names of items I want to pick-up
    DropsCount will keep track of my pick-ups
    }

    var
      Drops: TStringArray;
      DropsCount: TIntegerArray;

    {
    setupDrops will declare my variables
    Run this before the actuall pick-up function..
    }

    Procedure setupDrops;
    begin
      {Drops will always be case sensetive and will always need a full name}
      Drops := ['Bronze arrow',
                'Bones',
                'Rune chainbody', {This would work}
                'RuNe ChainBody', {This wouldn't}
                'Thread'];

      SetLength(DropsCount, Length(Drops));
    end;


    {
    After you've declared your drops it's time to search for them!
    }

    procedure handle_Drops;
    var
      Pile: TReflectGroundItemArray;
      I, Ind: Integer;
    begin
      Pile.GetAll(GroundItems_Dist); {Notice how I use GroundItems_Dist here}

      {If there's no items on the ground, Exit.}
      If Length(Pile) = 0 then
        Exit;

      {Searching through our items for the correct names given in the
       setup.}

      For I:=0 to High(Pile)do
        If InStrArrEx(Pile[I].Name, Drops, Ind)then {Tries to match grounditem name with our names for a match}
        begin
          Writeln(Pile[I].Name + ' found..');
          {We found a drop, and can now access it's location via Pile[I].Tile and pick it up}


          {To keep track of how many we picked up, we can simply do}
          DropsCount[Ind] := DropsCount[Ind] + Pile[I].Quantity;
        end;
    end;

    begin
      Reflect.Setup;
      setupDrops;

      handle_Drops;
    end.



    When finished you can print it out like I did





  2. #2
    Join Date
    Feb 2013
    Location
    Rimmington
    Posts
    319
    Mentioned
    33 Post(s)
    Quoted
    183 Post(s)

    Default Items, examples..

    • Name: String
    • ID: Integer
    • HighAlchValue: Integer
    • InvActions: TStringArray
    • GroundActions: TStringArray



    Everytime you're handling items in any format,
    • Bank
    • Inventory
    • Grounditems

    These variables will ALWAYS be access-able via itemDefs.

    So what does this mean?

    By using any .Get function you'll get all this information about the item.
    An example would be my small tutorial on grounditems using item names instead of ID's.

    Notice, just because SIMBA's codehint doesn't show all the variables in the type doesn't mean that they're not there. Instead try the code, compile it, and you'll see that it works!

    Your mind is the limit

  3. #3
    Join Date
    Jan 2013
    Posts
    68
    Mentioned
    0 Post(s)
    Quoted
    25 Post(s)

    Default

    Simba Code:
    procedure handle_Drops;
    var
      Pile: TReflectGroundItemArray;
      I, Ind: Integer;

    begin
      Pile.GetAll(GroundItems_Dist); {Notice how I use GroundItems_Dist here}
      If Length(Pile) = 0 then
        Exit;
      For I:=0 to High(Pile)do
        If InStrArrEx(Pile[I].Name, Drops, Ind)then {Tries to match grounditem name with our names for a match}
        begin
          Writeln(Pile[I].Name + ' found..');
          DropsCount[Ind] := DropsCount[Ind] + Pile[I].Quantity;
        end;
    end;

    So I get this error and can't figure it out.
    Error: Unknown declaration "Name" at line 186, column 26 at line 186
    Compiling failed.

    Also your small tutorial link you posted doesn't work.

    I got it working, nevermind.
    Last edited by Zace; 04-19-2015 at 05:40 PM. Reason: Figured it out.

  4. #4
    Join Date
    May 2013
    Posts
    98
    Mentioned
    1 Post(s)
    Quoted
    33 Post(s)

    Default

    Why take the time to edit your post to say you've worked it out and then not bother typing two lines to tell everyone else how to fix it?

    Edit: I figured it out, here's so the next guy doesn't have to waste their time on this.. you have to replace

    Simba Code:
    Pile[I].Name

    with

    Simba Code:
    Pile[I].GetName
    Last edited by EZ41; 05-02-2015 at 02:25 AM. Reason: Guy above me being inconsiderate

  5. #5
    Join Date
    Jan 2012
    Posts
    468
    Mentioned
    3 Post(s)
    Quoted
    200 Post(s)

    Default

    Nice script. Need to get 75+ Slayer so I can work on a project like this.

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
  •