Results 1 to 7 of 7

Thread: [Aerolib] Creating and using items

  1. #1
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    827
    Mentioned
    12 Post(s)
    Quoted
    343 Post(s)

    Default [Aerolib] Creating and using items

    Hi all,

    I thought I would whip up another Aerolib tutorial that explains how to identify and use items from your inventory and/or bank.

    This tutorial will assume that you have read the previous Aerolib tutorial, and that you are familiar with the basics of scripting in Aerolib.

    So lets begin!

    What are items?
    Items are the objects in your inventory and bank. These are the icons that represent real Runescape items like Iron ore, Gold bars, Coins, Herbs etc. The way we identify items is a little different to the way we identify world Objects like mining veins and banks.

    Flight has done the hard yards and created some includes inside of Aerolib that make item creation and interaction a breeze!

    Items can be identified using a few different processes, but we will be using a type called DTM (Deformable Template Models).

    DTMs use points, color and tolerence to identify an object. This usually consists of a main point in the centre of the item (usually on a colored section) and a series of points on the black outline. Every item in runescape has a black outline with the same color and tolerence.

    DTMs that need to identify items of a similar nature and structure can use multiple colors or even black counts to really refine the search.

    Creating a DTM
    Simba just so happens to include a DTM Editor.

    This is located in Tools > DTM Editor (a popup will appear).

    __________________________________________________ ________________________
    If the DTM Editor option does not exist, go to: View > Extensions.

    An interface will popup, the same interface you would have used when setting up Simba initially.

    Look for a line: dtm_editor.sex, highlight it, and click the enable check box.
    __________________________________________________ ________________________

    Before proceeding, ensure that you have the Runescape client loaded, and use the Crosshairs in Simba to target the client.

    The DTM editor looks like this:


    Now that you have the DTM editor open, click on: Image > Load client

    This will ensure that only the Runescape client is shown.

    Log your character in and have the item you wish to create in your inventory.

    If the picture on the DTM editor is outdated, click Image > Load client again.

    For the purpose of this tutorial, I will be using an Air Talisman.

    Click towards the centre of the object and find a prominent color. A flashing dot will appear and the box on the right will populate with some data.



    The data on the right is as follows:
    TPoint (578, 225)
    Color (10461099)
    Tolerence (0)
    Unimportant (1, 0)

    Now that we have our prime color, we want to trade the black outline. When you mouse over the picture, the box at the top right will populate with the color that your cursor is on. This makes selecting the black outline super easy. Once you have got the black outline under your cursor, click. You will see a color/tol value of 65536/0. If you see another color, you selected the wrong color and need to delete the point (Delete point button).
    You will also note a line from the centre point to this point.

    Proceed to do this around your DTM. The more points, the more accurate the identification of the DTM will be.



    Now that we have created the outline of our DTM, we want to set the tolerence value of the first point. This will be trial and error, as Runescape changes color every time you log in. I usually start with a value of 25 or so, but if the object is quite unique in shape, you can go higher.

    To change the value, go to the box on the right hand side where your data is populated and scroll to the top if required. Select the first color (it will be the only different color) and change the Tolerance field to your desired value.

    Once you have done that, it is time to save your DTM. Click FIle > Save DTM and then call it whatever you want.
    Once saved, close the DTM popup.

    Now we want to try the DTM out and see if Simba can identify it.

    Re-open the DTM Editor screen.

    Your picture will still be there, but your DTM won't be. Click Image > Load client again.

    Go to File > Open DTM and select your DTM that you created.

    It will appear at the top left corner of the editor - don't worry about this.

    Click Image > Show Matching DTMs.

    If a red cross appeared over your DTM, you were successful!
    If not, you need to adjust your tolerence and ensure that you only selected 1 color and the rest black lines.


    Best practice is to try this with the bank open and a copy of the item visible in your bank and your inventory to ensure identification. This also helps to filter out any other items that may identify which shouldn't.

    Now that we have successfully created our DTM, we want to generate some code for use in our script.

    With your DTM loaded, go to DTM > Print DTM

    A line of code will appear in the debug box that looks like this: DTM := DTMFromString('m6wAAAHicjcxZCoAwDEXRVxxAKyhOoLj3Lq Cb7C3Nh595cEJISKKkBRsunFgxo1fLgA4jos1qv+PAhxe33U62 zylRg8sjf3wfm18K8N8DMw==');

    Keep this information safe for use later on in the tutorial.

    Item functions and includes
    There are 2 includes that you will use frequently when it comes to Items: Items.Simba and Bank.Simba.

    ..Simba\Includes\AeroLib\entities\items\Items.Simb a
    ..Simba\Includes\AeroLib\core\Bank.Simba

    Items.Simba provides information on creating, interacting and using the items, while Bank.Simba includes limited functionality with the items.

    Have a read through both of the includes. Any function that uses a TItem can be used to interact with our item.

    Creating and interacting with an item in your script
    Now that we have created our DTM, it is time to create the item in our script.

    This is the mock script that I will be using for the purpose of this tutorial:
    Simba Code:
    program Tutorial;
    {$i AeroLib/AeroLib.Simba}

    Procedure LoadItem;
    begin

    end;

    Procedure UseItem;
    begin

    end;

    begin
      initAL;
      LoadItem();
      UseItem();
    end.
    The first thing we need to do is declare a variable as a TItem. This can called anything, but I like to call it something related to the item. In this case, it will be AirTally.
    Simba Code:
    program Tutorial;
    {$i AeroLib/AeroLib.Simba}

    var
      AirTally:TItem;

    Procedure LoadItem;
    begin

    end;

    Procedure UseItem;
    begin

    end;

    begin
      initAL;
      LoadItem();
      UseItem();
    end.

    Now we want to set the DTM to the item. Since TItem is a type, we simply type our variable name, followed by a .
    This should bring up a list of possible functions and variables we can use with this.

    We will be using AirTally.DTM.

    Simba Code:
    program Tutorial;
    {$i AeroLib/AeroLib.Simba}

    var
      AirTally:TItem;

    Procedure LoadItem;
    begin
      AirTally.DTM := DTMFromString('m6wAAAHicjcxZCoAwDEXRVxxAKyhOoLj3LqCb7C3Nh595cEJISKKkBRsunFgxo1fLgA4jos1qv+PAhxe33U62zylRg8sjf3wfm18K8N8DMw==');
    end;

    Procedure UseItem;
    begin

    end;

    begin
      initAL;
      LoadItem();
      UseItem();
    end.

    As you can see, we used the DTM information that we generated and assigned it to the AirTally TItem. This means that any functions that use a DTM that involve this item, will use the DTM we declare here.

    Now we want to interact with the item. There are a few ways to do this. I will list a few examples and explain them on the code below.

    Simba Code:
    program Tutorial;
    {$i AeroLib/AeroLib.Simba}

    var
      AirTally:TItem;

    Procedure LoadItem;
    begin
      AirTally.DTM := DTMFromString('m6wAAAHicjcxZCoAwDEXRVxxAKyhOoLj3LqCb7C3Nh595cEJISKKkBRsunFgxo1fLgA4jos1qv+PAhxe33U62zylRg8sjf3wfm18K8N8DMw==');

    end;

    Procedure UseItem;
    var
      pnt: TPoint;
    begin
      // TIem.InInventory returns a boolean result to see if our item is in our inventory.
      if AirTally.InInventory then
        WriteLn('Found Item in inventory!');

      // TItem.FIndIn(Area:Tbox, var Tpoint) returns a boolean and provides us with a TPoint if our item is found in our inventory.
      if AirTally.findIn(Area_Inv, pnt) then
        WriteLn('Found Item in our inventory and stored its location on variable: pnt');

      // TItem.GetSlot returns an integer for the first slot that has our item in it.
      WriteLn('The first slot our item is location in is: ' +IntToStr(AirTally.GetSlot));

      // TItem.Interact(mouse varient) finds and interacts with the first instance of our item.
      if AirTally.interact(MOUSE_RIGHT) then
        WriteLn('We found the item in our inventory and right clicked on it!');
      // TItem.GetAmount(Exclude bank) returns an integer with the quantity of our item that is found on the MS. Exclude bank excludes the bank and searches only in the inventory.
      WriteLn('We have: ' +IntToStr(AirTally.getAmount(True)) + ' of our item in our inventory');
    end;

    begin
      initAL;
      LoadItem();
      UseItem();
    end.

    As you can see, there are many ways for us to interact with our item.

    Items.Simba has also has the a function called GetSlots that will get the slot number of each Inventory slot that contains the item, and returns it as a TIntegerArray.
    I will show you how this works.

    Say for instance we are power mining iron ore. We want to keep the valuable gems that we mine and only drop the Iron ore. This is possible to do with the following script:
    Simba Code:
    program Tutorial;
    {$i AeroLib/AeroLib.Simba}

    var
      IronOre:TItem;

    Procedure LoadItem;
    begin
      IronOre.DTM := DTMFromString('m6wAAAHicjcxZCoAwDEXRVxxAKyhOoLj3LqCb7C3Nh595cEJISKKkBRsunFgxo1fLgA4jos1qv+PAhxe33U62zylRg8sjf3wfm18K8N8DMw==');
    end;

    Procedure DropOre;
    var
      pnt: TPoint;
      i: integer;
      TempArray: TIntegerArray;
    begin
      TempArray := IronOre.getSlots();                    //Stores the slot numbers that contain our item (1 to 28).
      for i := low(TempArray) to high(TempArray) do       //Sets the variable i to the lowest slot number found with our item and repeats all numbers inbetween and up to our highest slot number with our item.
      begin
        MouseBox(InvBox(TempArray[i]), MOUSE_MOVE);                  //Mouses over a random part of the slot that contains our item.
        if IsUpTextMulti(['Iron', 'ore', 'ron or']) then  //Checks the uptext of the item to see if it indeed the item we are looking for.
          if InteractSlot(TempArray[i], MOUSE_RIGHT) then            //Interacts with the slot by right clicking.
            if WaitOption('drop', 1000) then              //Waits for the option 'drop' to exist after right clicking.
              ChooseOption('drop');                       //Chooses the option drop after we confirm the option exists.
      end;                                                //if i is less than high, this function repeats again, but with i being the next highest value found in the array.
    end;

    begin
      initAL;
      LoadItem();
      DropOre();
    end.

    I have added comments in the script itself that talk you through the process. For..To..Do is a very powerful tool in scripting and should be used often
    Last edited by Dan the man; 08-08-2017 at 05:42 AM.

  2. #2
    Join Date
    Aug 2014
    Location
    Australia
    Posts
    932
    Mentioned
    53 Post(s)
    Quoted
    495 Post(s)

    Default

    Another excellent tutorial, well done. If I may, I suggest that you add a link to this tutorial at the end of your previous tutorial. It's obvious that this is intended to be a "part 2" of sorts, so it'd be a good idea to link them together.



    New to scripting? Procedures & Functions for Beginners
    Do you use your computer at night? Just get f.lux

  3. #3
    Join Date
    Oct 2011
    Location
    England
    Posts
    399
    Mentioned
    10 Post(s)
    Quoted
    176 Post(s)

    Default

    Good stuff dude, especially for the newcomers!
    Yer a wizard, 'oopi

  4. #4
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    827
    Mentioned
    12 Post(s)
    Quoted
    343 Post(s)

    Default

    Quote Originally Posted by Incurable View Post
    Another excellent tutorial, well done. If I may, I suggest that you add a link to this tutorial at the end of your previous tutorial. It's obvious that this is intended to be a "part 2" of sorts, so it'd be a good idea to link them together.
    Good idea. Done.

    Quote Originally Posted by anth_ View Post
    Good stuff dude, especially for the newcomers!
    Thanks

  5. #5
    Join Date
    Mar 2015
    Posts
    12
    Mentioned
    1 Post(s)
    Quoted
    7 Post(s)

    Default

    How to have multiple DTMs in 1 script. Do you use multiple tpoints, or do you only use that once?

  6. #6
    Join Date
    Jan 2013
    Posts
    84
    Mentioned
    0 Post(s)
    Quoted
    23 Post(s)

    Default

    Quote Originally Posted by Scornical View Post
    How to have multiple DTMs in 1 script. Do you use multiple tpoints, or do you only use that once?
    If you were saving the pnts of both items at the same time you would need 2 different points yeah, which would look something like this;

    Code:
    program Tutorial;
    {$i AeroLib/AeroLib.Simba}
    
    var
      AirTally, Shark:TItem;
    
    Procedure LoadItem;
    begin
      AirTally.DTM := DTMFromString('m6wAAAHicjcxZCoAwDEXRVxxAKyhOoLj3LqCb7C3Nh595cEJISKKkBRsunFgxo1fLgA4jos1qv+PAhxe33U62zylRg8sjf3wfm18K8N8DMw==');
      Shark.DTM := DTMFromString('m1gAAAHic42KAgB//////DsTfgJgbyAdS/1mBNB8Qg8S/AjFI3Ucg/QWIQer/ATETUAykjgOIQfp4waYxAjETQSwCVUktjAAArM0oFw==');
    end;
    
    Procedure UseItem;
    var
      pnt, pnt2: TPoint;
    begin
      // TIem.InInventory returns a boolean result to see if our item is in our inventory.
      if AirTally.InInventory then
        WriteLn('Found AirTally in inventory!');
      if Shark.inInventory then
        WriteLn('Found Shark in inventory!');
    
    // TItem.FIndIn(Area:Tbox, var Tpoint) returns a boolean and provides us with a TPoint if our item is found in our inventory.
      if AirTally.findIn(Area_Inv, pnt) then
        WriteLn('Found AirTally in our inventory and stored its location on variable: pnt');
      if Shark.findIn(Area_Inv, pnt2) then
        WriteLn('Found Shark in our inventory and stored its location on variable: pnt2');
      
    // TItem.GetSlot returns an integer for the first slot that has our item in it.
      WriteLn('The first slot our AirTally is location in is: ' +IntToStr(AirTally.GetSlot));
      WriteLn('The first slot our Shark is location in is: ' +IntToStr(Shark.GetSlot));
      
    // TItem.Interact(mouse varient) finds and interacts with the first instance of our item.
      if AirTally.interact(MOUSE_RIGHT) then
        WriteLn('We found the AirTally in our inventory and right clicked on it!');
      if Shark.interact(MOUSE_RIGHT) then
        WriteLn('We found the Shark in our inventory and right clicked on it!');
     
    // TItem.GetAmount(Exclude bank) returns an integer with the quantity of our item that is found on the MS. Exclude bank excludes the bank and searches only in the inventory.
      WriteLn('We have: ' +IntToStr(AirTally.getAmount(True)) + ' of AirTally in our inventory');
      WriteLn('We have: ' +IntToStr(Shark.getAmount(True)) + ' of Shark in our inventory');
    end;
    
    begin
      initAL;
      LoadItem();
      UseItem();
    end.

  7. #7
    Join Date
    Sep 2014
    Location
    C:\Simba\
    Posts
    557
    Mentioned
    9 Post(s)
    Quoted
    71 Post(s)

    Default

    Please clarify what you're trying to achieve @Scornical;
    Feel free to ask me any questions, I will do my best to answer them!

    Previously known as YouPee.

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
  •