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
  • Simply Selecting an Item


    lobbyplox

    Recommended Posts

    Hi everyone, I have a quick question regarding a scripting function. I'm having trouble finding the function to select an item in your inventory? Could anyone help me out here?

     

    Thanks

    Link to comment
    Share on other sites

    getInventory().get("ItemName")
    or
    getInventory().get("ItemName").interact("Use");
    

    to add onto this there is also a useOn option:

     

    getInventory().get("Item").useOn("Item2");
    
    Link to comment
    Share on other sites

    Another question, related to this one:

     

    Is it a similiar command to interact with an NPC?

    I'm using

     

    NPC = getNpcs().closest(f-> f.getName().contains("npc name"));
    NPC.interact("Use");

     

    but am having trouble, could it be because they are out of vision? and if so How could I move nearby the NPC.

     

     

    Link to comment
    Share on other sites

    Another question, related to this one:

     

    Is it a similiar command to interact with an NPC?

    I'm using

     

    NPC = getNpcs().closest(f-> f.getName().contains("npc name"));

    NPC.interact("Use");

     

    but am having trouble, could it be because they are out of vision? and if so How could I move nearby the NPC.

    You need to null check the npc and check if the npc is on screen. If the npc is not on your screen you can grab the distance of the npc to determine whether you should turn your camera or walk to the NPC. To use an item on an npc you can use getInventory().get("Item").useOn(npc);. I suggest you learn some java (if you havn't already) and look at some open source scripts to get a better understanding on how to use the API, and how to form the logic of your script.

    Link to comment
    Share on other sites

    You need to null check the npc and check if the npc is on screen. If the npc is not on your screen you can grab the distance of the npc to determine whether you should turn your camera or walk to the NPC. To use an item on an npc you can use getInventory().get("Item").useOn(npc);. I suggest you learn some java (if you havn't already) and look at some open source scripts to get a better understanding on how to use the API, and how to form the logic of your script.

    Thanks. Yeah I've done a handful of C and C++ before, so I've ran into a little learning curve here. I appreciate your advice!

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • 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.