Question How to make gold bracelets at furnace

Discussion in 'Developer Support' started by 43zombiegit, Aug 25, 2020.

  1. 43zombiegit

    Joined:
    Aug 20, 2020
    Messages:
    1
    Likes Received:
    0
    Hi guys, so I've been working on a gold bracelet making bot. Here is the function used to smelt once the bot has detected a full inventory of gold bars and a mould:

    public void execute() {
    GameObject furnace = GameObjects.newQuery().within(furnace_area).names("Furnace").results().nearest();
    System.out.println(furnace);
    if (furnace != null) {
    if (furnace.isVisible()) {
    furnace.interact("Smelt");
    InterfaceComponent makegoldbracelet = Interfaces.getAt(446, 46);
    if (makegoldbracelet.click()) {
    Execution.delayUntil(() -> Inventory.getQuantity("Gold bracelet") == 27, 30000, 50000);
    }

    }
    }
    }
    }

    I keep getting a null pointed exception which I think is the fact that the makegoldbracelet variable is null until the interface is opened. How do I delay until the furnace interface is open? The bank has the .isOpen() function but I'm not sure how to apply that in this situation.

    Many thanks.
     
  2. CuppaJava

    CuppaJava Makes a Lot of Bots

    Joined:
    Mar 13, 2018
    Messages:
    2,709
    Likes Received:
    827
    Crafting uses the makeallinterface, I think? If so you can use MakeAllInterface.isOpen(), along with other MakeAllInterface methods. Generated Documentation (Untitled)

    Using your current code, you could probably also do
    Code (Text):
    1. if(makegoldbracelet!=null){
    2.      if(makegoldbracelet.click){
    3. //...
    A few other minor things: you should nullcheck the return of
    Code (Text):
    1. GameObjects.newQuery().within(furnace_area).names("Furnace").results()
    it can return null.

    also make sure you're only ever going to execute one action per loop, generally. Because right now if furnace is visible, it'll attempt to interact "Smelt" and then also make a gold bracelet. You should restructure this so that if the "makegoldbracelet" is visible, click it, and if not then check if the furnace is visible and if it is then "Smelt" otherwise walk to it.

    Something like
    Execution.delayUntil(()-> (makegoldbracelet = Interfaces.getAt(446, 46)) != null , 5000, 7000);


    Also join the discord, you'll get more responses.
     
    43zombiegit likes this.

Share This Page

Loading...