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
  • My script will not start


    pims1997

    Recommended Posts

    I built a little script for myself, that will take copper and iron from my bank and smelt them at a furnace (in lumbridge).

     

    The problem is that suddenly, when I build the artifact it will not start when I press the start script button on the script panel in the dreambot client.

     

    I am really confused as to what it might be...

     

    Note: It did work before when it just walked to the bank...

    (The script below is not done yet, I just want to test if it works with the current code)

    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.container.impl.bank.BankLocation;
    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.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.utilities.impl.Condition;
    import org.dreambot.api.wrappers.interactive.Entity;
    import org.dreambot.api.wrappers.interactive.GameObject;
    import org.dreambot.api.wrappers.interactive.NPC;
    
    @ScriptManifest(name = "PimsLumbridgeSmelter", version = 1.0, description = "Lumbridge Smelting", category = Category.SMITHING, author = "Pims")
    public class MainClass extends AbstractScript {
    
    
        Area bankArea = BankLocation.getNearest(getLocalPlayer()).getArea(2);
        Tile smeltery = new Tile(3227, 3255);
        //walk to nearest bank
        //take 14 tin and 14 copper
        //walk to furnace
        //smelt bronze
        //walk to nearest bank
        //bank bars
    
        private boolean startScript = true;
    
        @Override
        public void onStart() {
            log("starting up");
        }
    
        @Override
        public int onLoop() {
            //walk to nearest bank
            if (startScript) {
                if (getInventory().onlyContains(item -> item != null && item.getName().contains(" ore"))) {
                    if (getLocalPlayer().getTile().equals(smeltery)) {
                        Smelt();
                    } else {
                        WalkToSmelter();
                    }
                }
    
    
                if ((getInventory().isFull() && !getInventory().onlyContains(item -> item != null && item.getName().contains("ore")))
                        || getInventory().onlyContains(item -> item != null && item.getName().contains(" bar"))) {
                    if (bankArea.contains(getLocalPlayer())) {
                        Bank();
                    } else {
                        WalkToBank();
                    }
                }
    
    
            }
    
            return 600;
        }
    
        public void WalkToSmelter() {
            if (getWalking().walk(smeltery.getTile())) {
                sleep(Calculations.random(3000, 6000));
            }
        }
    
        public void WalkToBank() {
            if (getWalking().walk(bankArea.getCenter())) {
                sleep(Calculations.random(3000, 6000));
            }
        }
    
        public void Smelt(){
            GameObject furnace = getGameObjects().closest(gameObject -> gameObject != null && gameObject.getName().equals("Furnace") && gameObject.hasAction("Smelt"));
    
            if(furnace != null && furnace.interact("Smelt")){
                log("Smelting bars");
                if(sleepUntil(() -> (getWidgets().getWidget(270) != null), 8000)){
                    log("okay");
                }
                log("not okay");
    
                log("Done sleeping for Furnace");
            }
        }
    
        public void Bank() {
            NPC banker = getNpcs().closest(npc -> npc != null && npc.hasAction("Bank"));
    
            if (getBank().isOpen() || (banker != null && banker.interact("Bank") && sleepUntil(() -> !getInventory().isFull(), 9000))) {
                if (getBank().depositAllItems()) {
                    if (sleepUntil(() -> !getInventory().isFull(), 8000)) {
                        if (getBank().withdraw(item -> item != null && item.getName().equals("Tin ore"), 14)
                                && getBank().withdraw(item -> item != null && item.getName().equals("Copper ore"), 14)) {
                            if (sleepUntil(() -> getInventory().isFull(), 8000)) {
                                if (getBank().close()) {
                                    sleepUntil(() -> !getBank().isOpen(), 8000);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    
    
    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.