Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Question NewQuery() usage

Joined
Jul 28, 2016
Messages
13
Hello,

I've made a fletching bot succesfully with the state method and I've also managed to make a good GUI for it using embeddableUI and SceneBuilder.
I'm, however, having a hard time understanding newQuery(). In my bot for example, I have a menu option for the type of log to use and which item to make.

Now the options for the item are "Arrow shaft", "shortbow", "stock" and "shieldbow". If, for example, "shortbow" is selected I want to find the option for the shortbow in the make x interface. The problem here is I only have part of the name "Maple shortbow" so I have to find the option which contains a item which has "shortbow" in it's name and click it. Currently I'm using Interfaces.getAt() to get the interface container and component then i have a for loop to go through each subcomponent and see which contains the item which has "shortbow" in it's name and click it. I want to find the option by it's partial name so that the user doesn't need to type the name in the menu nor do I have to get full names od the items myself to have to write them down.

I'm willing to contribute to the community and make bots, but I want to make sure I'm using the most efficient and proper coding first. If someone could also shortly explain or give examples of predicates and newQuery() I'd appreciate it.
 
Last edited:
Client Developer
Joined
Oct 12, 2015
Messages
3,781
Hi,

First off you should join the #development channel on Slack.

Secondly, you can use .#newQuery().texts() with regards to interfaces. You should familiarise yourself with the JDocs. Predicates essentially just validate an object using a boolean and, if it returns true, add it to the list of results. Example usage:
Code:
Npc yak = Npcs.newQuery().names("Yak").actions("Attack").within(yaks.getYakPen()).filter(new Predicate<Npc>() {
            @Override
            public boolean test(Npc npc) {
                return npc.getTarget() == null
                        && npc.getHealthGauge() == null;
            }
}).results().first();

I believe there was also functionality added in the last release with regards to the MakeX interface, courtesy of @SlashnHax.
 
Top