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
  • SourB Al Kharid Bronze Bar Smelter (Discontinued)


    SourBear

    Recommended Posts

    !! DISCONTINUED !!

    *Steal the code if you want, don't really care too much*

    SourB Al Kharid Bronze Bar Smelter

    *This is a project to help me learn about scripting not make a fully fledged script*

     

    Summary -

    So recently a lot of script I've tried for some reason or another just don't seem to work quite right for me. For example I cant get any smelting scripts to work for me so I've taken it upon my self to further my scripting knowledge and to make my own smelting script. The reason simply is because whenever I use one of the scripts I make, they work fine. So, to begin I don't have much experience in the way of scripting. If I was to describe my scripting, I'd say its pretty much limited to a lot of 'if this, than do this'. Now that you know I'm sure you'll straight away notice it in my code.

    What I want -

    *This is simply what I want to get out of this script*

    - The script should be able to be started in Al Kharid, this means I don't want it to be 'start like this'. This is to make the script easy to use.

    - The script should be able to withdraw the ore, walk to the smelter and smelt it, then walk back to the bank and deposit the bars and then repeat.

    What don't want -

    *This is simply what I cant be fucked including*

    - I don't wanna include a start up gui

    - I don't wanna include paint

    - I don't really wanna include some stats such as bars smelted but if it's easy I might

    - I don't wanna make it crazy advanced, as in you can start it in a boss fight and it'll kill the boss just so that it can reach Al Kharid to smelt some bronze bars for you. I just want it to be simple and too the point (besides how the code functions cause I'm lazy).

    What I've got -

    *This is what I have coded so far and after is the issues*

    package org.dreambot.sourb;
    
    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.wrappers.items.GroundItem;
    import org.dreambot.api.wrappers.widgets.WidgetChild;
    import org.dreambot.api.utilities.impl.Condition;
    
    @ScriptManifest(author = "SourB", category = Category.SMITHING, description = "Smelts Bronze Bars in Al Kharid", name = "SourB Al Kharid Bronze Bar Smelter", version = 1.0)
    
    public class Main8 extends AbstractScript {
    
        public static final int COPPER_ORE = 436;
        public static final int TIN_ORE = 438;
        public static final int BRONZE_BAR = 2349;
        public static final int FURNACE = 24009;
    
        private static Area BANKING_AREA = new Area(3269, 3167, 3270, 3165);
        private static Area FURNACE_AREA = new Area(3274, 3186, 3274, 3186);
    
        @Override
        public int onLoop() {
    
            if (!FURNACE_AREA.contains(getLocalPlayer()) && getInventory().contains(COPPER_ORE)) {
                log("Walking to Furnace");
                getWalking().walk(FURNACE_AREA.getRandomTile());
            } else if (FURNACE_AREA.contains(getLocalPlayer()) && getInventory().contains(COPPER_ORE, TIN_ORE)) {
                log("Interacting with Furnace");
                getGameObjects().closest(FURNACE).interact();
                WidgetChild makeAllWidg = getWidgets().getWidgetChild(270, 14);
                if (makeAllWidg != null && makeAllWidg.isVisible()) {
                    if (makeAllWidg.interact("Smelt")) ;
                    log("Sleeping after smelting");
                    sleep(36000);
                }
            } else if (!BANKING_AREA.contains(getLocalPlayer()) && getInventory().contains(BRONZE_BAR)) {
                log("Walking to bank");
                getWalking().walk(BANKING_AREA.getRandomTile());
            } else if (BANKING_AREA.contains(getLocalPlayer()) && !getInventory().contains(COPPER_ORE)) {
                if (getBank().isOpen()) {
                    log("Is bank open");
                    if (getInventory().isFull()) {
                        log("Banking");
                        getBank().depositAll(BRONZE_BAR);
                        getBank().withdraw(COPPER_ORE, 14);
                        getBank().withdraw(TIN_ORE, 14);
                    }
                }else if (BANKING_AREA.contains(getLocalPlayer()) && !getBank().isOpen()) {
                    log("Go to bank");
                    getBank().open(BankLocation.AL_KHARID);
                }
            } else if (!BANKING_AREA.contains(getLocalPlayer()) && !FURNACE_AREA.contains(getLocalPlayer()) && !getInventory().contains(COPPER_ORE, BRONZE_BAR)) {
               log("Walking to bank (nothing in inv)");
                getWalking().walk(BANKING_AREA.getRandomTile());
            }
    
            return 1000;
        }
    
    
    }

    Download -

    SourB Bronze Bar Smelter.jar

     

    The CURRENT problem I need to fix -

    Currently if you start the script with nothing in your inventory or if you have bronze bars in it (as in you just finished smelting some) it'll walk to the bank fine, then will get stuck at this piece of code.

    else if (!getBank().isOpen()) {
                    log("Go to bank");
                    getBank().open(BankLocation.AL_KHARID);
                }

    If I look at the debug console it does in fact print to the console 'Go to bank' like its suppose to but, it will sit in the BANKING_AREA and do nothing. It will understand what it has to do as it will print 'Go to bank' over and over but it won't actually open the bank. Any help is very appreciated!

    Final notes -

    Thank you if you bother to contribute I very much appreciate it and don't worry, as I upgrade the script I'll update the download so I can share my creation. P.S. I'm very new to this, this is probably the most advanced thing I have attempted so go easy if I ask a obvious or irrelevant question. 

    Thank you for reading,

    -SourBear

     

    Patch notes -

    V1.0 - 11/18/2018 Initial release

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    Link to comment
    Share on other sites

    Good job, keep it up. Some little bits of advice:

     

    Your variables don't need to be static final in this case, they can be private as they aren't accessed externally, but initialising them as final is fine, seen as the ID value won't be changing. Another small thing may be slightly modifying logic (not completely necessary, but may help avoid potential hiccups if our account ends up in an unsupported spot).

     

    For instance:

     

    11 hours ago, SourBear said:

    if (BANKING_AREA.contains(getLocalPlayer())

    Could be:

    if !(FURNACE_AREA.contains(getLocalPlayer()

     

    Link to comment
    Share on other sites

    11 hours ago, Pseudo said:

    Good job, keep it up. Some little bits of advice:

     

    Your variables don't need to be static final in this case, they can be private as they aren't accessed externally, but initialising them as final is fine, seen as the ID value won't be changing. Another small thing may be slightly modifying logic (not completely necessary, but may help avoid potential hiccups if our account ends up in an unsupported spot).

     

    For instance:

     

    Could be:

    
    if !(FURNACE_AREA.contains(getLocalPlayer()

     

    Hey, just wanted to say thank you for the help! I'm working on it again this arvo, your help again is very appreciated very much and I hope you have a good one.

    -SourBear

    Link to comment
    Share on other sites

    7 hours ago, SourBear said:

    Hey, just wanted to say thank you for the help! I'm working on it again this arvo, your help again is very appreciated very much and I hope you have a good one.

    -SourBear

    You're very welcome, keep at it. If you need any help I'm always available via PM.

    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.