LoremIpsum213 0 Posted April 2, 2023 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?
hashbang 8 Posted April 9, 2023 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!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now