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
  • How to make a combat script


    qbots

    Recommended Posts

    Thanks for showing me the Lamba expressions :P. Now i have to keep it stuck in memory while I am coding.

     

    Edit: ETA on eating tutorial?

    Link to comment
    Share on other sites

    Here is an example of this with eatting and banking that might help you.

    http://pastebin.com/raw.php?i=k7WkBfp8

    private String food = "Monkfish";
    

    you could make it use any food if you did this

    private String[] food = {"food 1","Food 2"}; // and so on
    

    also what is this used for? 

    if(fixxx.contains(getPlayers().localPlayer().getTile())
    
    

    still learning this API

    Link to comment
    Share on other sites

     

    private String food = "Monkfish";
    
    you could make it use any food if you did this

    private String[] food = {"food 1","Food 2"}; // and so on
    
    also what is this used for? 

    if(fixxx.contains(getPlayers().localPlayer().getTile())
    

     

    To eat, just do

     

    private void eatFood() {
        if (getCombat().getHealthPercent() < whatever) {
            getInventory().interact(i -> i.getName(foodName), "Eat");
        }
    }
    
    Link to comment
    Share on other sites

    To eat, just do

     

    private void eatFood() {
        if (getCombat().getHealthPercent() < whatever) {
            getInventory().interact(i -> i.getName(foodName), "Eat");
        }
    }
    

    Yeah thanks for this. Still getting used this the API :D

    Yeah thanks for this. Still getting used this the API :D

    Does the Dreambot API have webwalker?

    Link to comment
    Share on other sites

    Yes, getWalk() will use the web walker that Dreambot has. (I believe)

    awesome! thanks for the helpful information!

    Link to comment
    Share on other sites

    • 2 weeks later...

    For eating, you dont need to set a specific name.

     

    Example:

    String foodName = null;
    
    public int onLoop() {
      if(foodName == null) {
        Item i = getInventory().get(item -> item != null && item.hasAction("Eat"));
            if(i != null) foodName = i.getName();
      } else {
        Item i = getInventory().get(item -> item != null && item.hasAction("Eat"));
        if(i != null) i.interact("Eat");
      }
    
    return 10;
    }
    

    This will set foodName when you start the script with food. Then when/if you add banking the script will know what to withdraw. (This removes the need for adding a field to the GUI)

    Link to comment
    Share on other sites

    • 1 month later...
    currentNpc = getNpcs().closest(npc -> npc != null && ...);
    if(currentNpc != null) {
    
    }
    

    This is why null is bad (haters can hate).

     

    You already check for null when you filter, so currentNpc will not be null.

     

    Yet you still do another null check. This happens quite a bit without people realizing.

     

    Double check your null checks! (or remove null from the equation)

    Link to comment
    Share on other sites

    currentNpc = getNpcs().closest(npc -> npc != null && ...);
    if(currentNpc != null) {
    
    }
    

    This is why null is bad (haters can hate).

     

    You already check for null when you filter, so currentNpc will not be null.

     

    Yet you still do another null check. This happens quite a bit without people realizing.

     

    Double check your null checks! (or remove null from the equation)

     

     

    It could still be null if there are no npcs that match the filter :)

    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.