Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • Commands for inventory? (don't really know how to read the API that well)


    Computor
     Share

    Recommended Posts

    First off, a lesson in reading the API would be very effective. I understand the substrings inside the api, for example, if you click on inventory it lists this:

     

    boolean interactWithSlot(int slot, java.lang.String action)

    Interacts with specified slot in inventory

    boolean isEmpty()

    Checks if your Inventory is empty

    boolean isEmptySlot(int slot)

    Checks if the slot is empty

    boolean isFull()

    Checks if your Inventory is full

    boolean isFullSlot(int slot)

    Checks if the slot has an Item in it

    boolean isItemSelected()

    Checks whether an item is currently selected in your inventory
     
     

    Which I understand completely. What I don't understand is how do I use them....

     

     

    Is it inventory.isFull(); ???

    On OSBot inventory.* would work, I don't know what it is on dreambot, and I don't know if there is a way to find it on the API or not. Please let me know!!

    Edited by Computor
    Link to comment
    Share on other sites

    So it's different and the same to osbot. In osbot they had constructors such as getInventory(), but they also had shorthand inventory (getInventory() was better btw!).

    Here there's just getInventory(), much like getWidgets() or getBank() etc etc.

     

    To access a method from the API, you just need to use the correct constructor which correlates to that command, eg getInventory().isFull() or getBank().isOpen()

     

    Apaec

    Link to comment
    Share on other sites

    So it's different and the same to osbot. In osbot they had constructors such as getInventory(), but they also had shorthand inventory (getInventory() was better btw!).

    Here there's just getInventory(), much like getWidgets() or getBank() etc etc.

     

    To access a method from the API, you just need to use the correct constructor which correlates to that command, eg getInventory().isFull() or getBank().isOpen()

     

    Apaec

    it called a method not a constructor and how is that better?

     

    constructor is method with no return type and named same as class

     

    e.g.

     

    public class Example {

      

        public Example() { //<-- this is constructor!!!1

           .....

        }

     

    }

    Edited by hakerman72
    Link to comment
    Share on other sites

    A quick lesson on docs:
    If you go to Inventory and you see all of those methods, that means those methods are in the Inventory class.

    You'll see some of them at the top of the page will say "extends X" or "implements Y"

    That means that class can access the methods of X/Y without any additional code.

    For instance:
    AbstractScript extends MethodContext

    And as such, AbstractScript can use all of MethodContext's methods without doing something like:
    MethodContext ctx = new MethodContext();

    ctx.stuff();

     

    Instead it's just

    stuff();

     

    So now that you know which class has the methods you're looking for, you need to figure out how to access it.

    As Pandemic nicely added, the MethodContext is where most of the stuff you need is located. These would be the major areas of the API:
    Client, Bank, Inventory, Skills, Walking, Map, etc.

     

    To access these (this is where the extend MethodContext comes in handy) simply find the method you want in the docs (Ctrl+F Inventory and you'll find "getInventory()")

    Now go to your script

    type getInventory()

    you can access all of Inventory's methods from here.

    getInventory().stuff();

     

    I actually forgot what I was doing half way through writing this, so pls forgive if I stopped making sense/switched what I was talking about.

    Link to comment
    Share on other sites

     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.