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
  • Script does nothing upon start.


    Rubick

    Recommended Posts

    When I start the script literally nothing happens. No cursor movement or anything. Any idea why?

    package main;
    
    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.wrappers.interactive.GameObject;
    import org.dreambot.api.utilities.impl.Condition;
    
    
    /**
     * Created by Rubick on 7/5/2017.
     */
    
    @ScriptManifest(category = Category.MONEYMAKING, name = "FeatherGrab", author = "Rubick", version = 0.1)
    
    public class Main extends AbstractScript {
    
        private int state;
        private int counter;
        private GameObject groundFeather;
    
        public void onStart(){
            state = 0;
            counter = 0;
        }
    
        Condition isValid = new Condition() {
            public boolean verify() {
                return groundFeather == null;
            }
        };
    
        @Override
        public int onLoop() {
            if (state ==0) {
                pickFeather();
            }
    
            return Calculations.random(500, 1000);
        }
    
        private void pickFeather() {
            groundFeather = getGameObjects().closest(f -> f.getName().contains("Feather"));
            counter = getInventory().count("Feather");
            if (groundFeather != null) {
                if (groundFeather.interact("Take")){
                    sleepUntil(isValid, Calculations.random(500, 1000));
                   
                }
            }
        }
    }
    
    
    Link to comment
    Share on other sites

    Use groundItem (i believe it's called) instead of gameObject, in your pickFeather() method.

     

    Message me on discord or skype if you have more questions, I'd be happy to help :)

    Link to comment
    Share on other sites

    And on top of that, you won't need "state".

     

    Just loop pickfeather method. Saves some bytes :kappa:

     

     

    Or, you can add a banking method and make it state = 1, so when your inventory is full set the state to 1.

     

     

    And also: counter = getInventory().count("Feather"); will constantly reset your counter to the amount of feathers in your inventory. To avoid this, do something like this:

     private void pickFeather() {
            groundFeather = getGameObjects().closest(f -> f.getName().contains("Feather"));
            counter = getInventory().count("Feather");
            if (groundFeather != null) {
                if (groundFeather.interact("Take")){
                    sleepUntil(isValid, Calculations.random(500, 1000));
                    counter++; //This will add 1 to the counter.
                }
            }
        }
    
    

    Because in your current code, each time you call the method it counts your inventory, meaning that it will count the first feather as 1, but when you pick your next feather, it will count 2 which makes your total count 3 instead of 2.

    Link to comment
    Share on other sites

    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.utilities.impl.Condition;
    import org.dreambot.api.wrappers.items.GroundItem;
    import org.dreambot.api.methods.Calculations;
    
    @ScriptManifest(author = "yabruh", name = "Feathers", version = 0.1, description = "pick up feather", category = Category.MISC)
    
    public class Main extends AbstractScript
    {
    
        private GroundItem groundFeather;
        private int counter;
    
        @Override
        public void onStart()
        {
            log("Starting the script.");
            counter = 0;
        }
    
        @Override
        public int onLoop()
        {
            pickUpFeather();
            //log("Feathers picked up " + counter);
            return Calculations.random(500,700);
        }
    
        private void pickUpFeather()
        {
            groundFeather = getGroundItems().closest("Feather");
            if (groundFeather != null)
            {
                groundFeather.interact("Take");
                sleep(500, 1500);
                sleepUntil(isValid, Calculations.random(500, 1000));
                //counter++;
            }
        }
    
        Condition isValid = new Condition()
        {
            public boolean verify()
            {
                return groundFeather == null;
            }
        };
    
        @Override
        public void onExit()
        {
            log("Stopping  the script.");
        }
    }
    
    

    I ran and tested this real quick, and it works for the most part.

     

    However, sometimes after picking up feathers it will right click (in the same spot it just looted from) several times. Essentially, it is looking at the drop down menu of the location and sees bones and raw chicken, without interacting with them, several times before moving on. The only other time it successfully uses a right click drop down menu, if there is a chicken standing on feathers, and it uses it to retrieve those feathers. 

    Link to comment
    Share on other sites

    Use groundItem (i believe it's called) instead of gameObject, in your pickFeather() method.

     

    Message me on discord or skype if you have more questions, I'd be happy to help :)

     

    Excellent, I've got it working now! Just need to tweak and fine tune. :) And yes, I will be adding you on Discord for sure. I greatly appreciate the help.

    And on top of that, you won't need "state".

     

    Just loop pickfeather method. Saves some bytes :kappa:

     

     

    Or, you can add a banking method and make it state = 1, so when your inventory is full set the state to 1.

     

     

    And also: counter = getInventory().count("Feather"); will constantly reset your counter to the amount of feathers in your inventory. To avoid this, do something like this:

     private void pickFeather() {
            groundFeather = getGameObjects().closest(f -> f.getName().contains("Feather"));
            counter = getInventory().count("Feather");
            if (groundFeather != null) {
                if (groundFeather.interact("Take")){
                    sleepUntil(isValid, Calculations.random(500, 1000));
                    counter++; //This will add 1 to the counter.
                }
            }
        }
    
    

    Because in your current code, each time you call the method it counts your inventory, meaning that it will count the first feather as 1, but when you pick your next feather, it will count 2 which makes your total count 3 instead of 2.

     

    I had the state in there for future use, such as banking like you said, or possibly killing the chickens also.

     

    As for the counter I actually wanted it to be the amount of feathers in my inventory. Since you gain more than 1 feather per loot I thought it would be easier to compare the amount of feathers in the inventory before the command to pick it up, with an if statement comparing the amount after the command and sleep to pick up the feather. But I don't really need to count the feathers at all, if it sleeps until the feather goes null or the timeout.

     

    Hope that made sense and I'm on the right track.

    Link to comment
    Share on other sites

    Excellent, I've got it working now! Just need to tweak and fine tune. :) And yes, I will be adding you on Discord for sure. I greatly appreciate the help.

     

    I had the state in there for future use, such as banking like you said, or possibly killing the chickens also.

     

    As for the counter I actually wanted it to be the amount of feathers in my inventory. Since you gain more than 1 feather per loot I thought it would be easier to compare the amount of feathers in the inventory before the command to pick it up, with an if statement comparing the amount after the command and sleep to pick up the feather. But I don't really need to count the feathers at all, if it sleeps until the feather goes null or the timeout.

     

    Hope that made sense and I'm on the right track.

    Oh yeah, of course.

     

    Then use: 

    private void pickFeather() {
            groundFeather = getGameObjects().closest(f -> f.getName().contains("Feather"));
                if (groundFeather.interact("Take")){
                    sleepUntil(isValid, Calculations.random(500, 1000));
                    counter = getInventory().count("Feather"); //You'd want to count after you've picked up the feathers for a more logical counting
                }
            }
        }
    

    Another method is to count the amount of picked feathers each time you pick them up.

    I forgot that you stack the items, so no need to count them "manually". Your method is valid, but i'd suggest you count after you pick up the feathers. For when you add banking, you want to save the amount of banked feathers and count from there on, E.G:

    bankedFeathers += getInventory().count("Feather"); //count them before you bank the feathers, then bank the feathers
    

    Not sure if the operator is "+=" or "=+". I think its the first one. This operator will count the feathers and add them to the current counted feathers. For example, of bankedfeathers = 200, and your inventory has 333, += will add 333 to 200. If you won't use += operator, it will override the current counted feathers, meaning it will reset the amount to 333 instead of 533.

    Link to comment
    Share on other sites

    Oh yeah, of course.

     

    Then use: 

    private void pickFeather() {
            groundFeather = getGameObjects().closest(f -> f.getName().contains("Feather"));
                if (groundFeather.interact("Take")){
                    sleepUntil(isValid, Calculations.random(500, 1000));
                    counter = getInventory().count("Feather"); //You'd want to count after you've picked up the feathers for a more logical counting
                }
            }
        }
    

    Another method is to count the amount of picked feathers each time you pick them up.

    I forgot that you stack the items, so no need to count them "manually". Your method is valid, but i'd suggest you count after you pick up the feathers. For when you add banking, you want to save the amount of banked feathers and count from there on, E.G:

    bankedFeathers += getInventory().count("Feather"); //count them before you bank the feathers, then bank the feathers
    

    Not sure if the operator is "+=" or "=+". I think its the first one. This operator will count the feathers and add them to the current counted feathers. For example, of bankedfeathers = 200, and your inventory has 333, += will add 333 to 200. If you won't use += operator, it will override the current counted feathers, meaning it will reset the amount to 333 instead of 533.

     

    Awesome, make sense. You sure a helpful Cardozz. Appreciate it man.

    Link to comment
    Share on other sites

    Awesome, make sense. You sure a helpful Cardozz. Appreciate it man.

    No problem. Hit me up when you have another question.

    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.