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 review


    pbjfreire

    Recommended Posts

    Hello i started scripting today and decided to write an iron mining script.

    public class main extends AbstractScript {
    public int onLoop() {
        if (getInventory().isFull())
    
            if (getBank().isOpen()) {
            getBank().depositAllExcept("bronze pickaxe");
    
            }else getBank().open(BankLocation.getNearest());
        else {
                GameObject rock = getGameObjects("Rocks");
                if(rock !=null){
                    rock.interact("Mine");
    
                }
            }
        return 1000;}
    }

    It is giving me errors but I dont understand whats wrong-

    Error 1- Error:(12, 42) java: method getNearest in enum org.dreambot.api.methods.container.impl.bank.BankLocation cannot be applied to given types;
      required: org.dreambot.api.wrappers.interactive.Entity
      found: no arguments
      reason: actual and formal argument lists differ in length

    Error 2- Error:(14, 31) java: method getGameObjects in class org.dreambot.api.methods.MethodContext cannot be applied to given types;
      required: no arguments
      found: java.lang.String
      reason: actual and formal argument lists differ in length

     Thank you for the help

    Link to comment
    Share on other sites

    GameObject rock = getGameObjects().closest(gameObject -> gameObject != null && gameObject.getName().equals("Rocks") && gameObject.hasAction("Mine"));

     

    Link to comment
    Share on other sites

    Quote

    GameObject rock = getGameObjects().closest(rock - > rock != null && rock.getName.equals("Rocks") && rock.hasAction("Mine"));

     
    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.wrappers.interactive.GameObject;
    
    @ScriptManifest(author = "pedro", name = "Miner", version = 1.0, description = "miner", category = Category.MINING)
    public class main extends AbstractScript {
    
        public void onStart() {
            log("made by pedro");
    
        }
    
        @Override
        public int onLoop() {
            if (getInventory().isFull())
    
                if (getBank().isOpen()) {
                    getBank().depositAllExcept("bronze pickaxe");
    
                } else getBank().openClosest();
            else {
                GameObject rock = getGameObjects().closest("Rocks");
                if (rock != null) {
                    rock.interact("Mine");
    
    
                }
                ;
            }
            return Calculations.random(500, 600); }
    }

    I ended up getting the script to look like this, but when i put it in the dreambot folder it doesnt show up in the client.

    Also thank you @Shy

    Link to comment
    Share on other sites

    Are you sure you are putting the jar in the right folder (Dreambot > Scripts) and are you looking in the right tab in Dreambot (Local Scripts). I copied your code and it shows in Dreambot for me. Also, If you have any other scripts in that folder remove them and see if it still doesn't show because if one script is messed up it will cause all scripts to not show.

    Link to comment
    Share on other sites

    I think you need to click the plus button right above the jar file( should say Add Copy of when you hover over it) in that screenshot and then click Module Output and add your Module to the jar file.

    Link to comment
    Share on other sites

    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.methods.map.Tile;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.wrappers.interactive.GameObject;
    
    @ScriptManifest(author = "pedro", name = "Miner", version = 1.0, description = "miner", category = Category.MINING)
    public class main extends AbstractScript {
    
        public void onStart() {
            log("made by pedro");
    
        }
    
        @Override
        public int onLoop() {
            if (getInventory().isFull())
    
                if (getBank().isOpen()) {
                    getBank().depositAllExcept("black pickaxe");
                    final Area VARROCK = new Area(3174, 3366, 3176, 3368);
                    {
    
                        getWalking().walk(VARROCK.getCenter());
    
                        sleep(Calculations.random(3000, 4000));
    
                    } while(!VARROCK.contains(getLocalPlayer()));
    
                } else getBank().openClosest();
            else {
                GameObject rock = getGameObjects().closest(11365);
                if (rock != null) {
                    rock.interact("Mine");
    
    
                }
                ;
            }
            return Calculations.random(500, 600); }
    }

    I tried experimenting with trying to get back to the mining spot after banking, however because the tile is out of reach the bot gets stuck and cant move after a certain point.

    Thanks for the help.

    -Pedro

    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.