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
  • Widget children do not contain item to be crafted?


    LoremIpsum213

    Recommended Posts

    Hi,

    I am making a fully featured crafting script, however i am facing one problem when crafting armour, and that is that the Widget Children do not contain any text string to which i can compare to.

    For making jewellery the following works:

    for (WidgetChild i : Widgets.getWidget(446).getChildren()) {
      if (i != null && i.hasAction(this.toString())) {
      Sleep.sleep(100, 2000);
      i.interact();
      Sleep.sleepUntil(Players.getLocal()::isStandingStill, () -> Players.getLocal().isAnimating(), 10000, 500, 3);
      break;
      }
    }

    Where this.toString() contains the name of the item to be crafted. the parent widget id for the Armour crafting menu is "270".

    For more context, I am talking about this menu. Is it possible to extract the names of the items somehow? or do i have to make some item -> WidgetID lookup table?

    image.png.4f8489c2a20434bc9aa70c13e55a4498.png

     

     

     

    Link to comment
    Share on other sites

    Each of those WidgetChilds have further children, but they don't show on the Widget Explorer.

    If you call WidgetChild.get(270, 14).getChildren() - You will get a list of 39 WidgetChild-ren with the same id (270, 14) but with an index from 0 to 38.

    For some reason, the final entry contains the Item you're looking for.

                WidgetChild wc = Widgets.get(270, 14);
                if (wc == null) {
                    return;
                }
                WidgetChild[] children = wc.getChildren();
                Logger.log(String.format("270, 14 has %d children", children.length));
                for (WidgetChild c : children) {
                    Logger.log(String.format("270, 14, %d  Item: %s", c.getIndex(), c.getItem()));
                }
    
    Produces the following log:
    
    2023-04-10 01:00:01 [INFO] 270, 14 has 39 children
    2023-04-10 01:00:01 [INFO] 270, 14, 0 Item: {name=,id=-1,amount=0,slot=-1}
    2023-04-10 01:00:01 [INFO] 270, 14, 1 Item: {name=,id=-1,amount=0,slot=-1}
    2023-04-10 01:00:01 [INFO] 270, 14, 2 Item: {name=,id=-1,amount=0,slot=-1}
    2023-04-10 01:00:01 [INFO] 270, 14, 3 Item: {name=,id=-1,amount=0,slot=-1}
    ... Truncated ...
    2023-04-10 01:00:01 [INFO] 270, 14, 36 Item: {name=,id=-1,amount=0,slot=-1}
    2023-04-10 01:00:01 [INFO] 270, 14, 37 Item: {name=,id=-1,amount=0,slot=-1}
    2023-04-10 01:00:01 [INFO] 270, 14, 38 Item: {name=Leather gloves,id=1059,amount=2147483647,slot=-1}  <- This is what you're looking for

     

    I suspect the easiest way to handle this, would be call `wc.getChildItems()` to a return a List<Item>, then iterate that and return the first item with a non-null id.

    I'm surprised by how awkward this is!

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    ×
    ×
    • 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.