Welcome!

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

Sign up now!

Tutorial Using The Results API

Engineer
Joined
Jul 28, 2013
Messages
2,776
Much of RuneMate's API is structured around the results API. The results API is a powerful and flexible strictly evaluated extension to both the traditional style API that many clients use and the lazily evaluated query API. Using the results API you can easily do the simple things such as getting the nearest npc from a results object

Traditional API
Code:
Npcs.getLoaded("Chicken", "Skeleton")|nearest()
Query API
Code:
Npcs.newQuery().names("Chicken", "Skeleton").results()|nearest()
Note: Dividers (|) have been placed at the point in the method chain where the traditional/query API usage changes into the results API usage.

while also being able to do the more complex things that would otherwise be rather difficult such as using an npc randomly taken from a list of the closest 3 npcs that are both visible and named chicken or skeleton

Traditional API
Code:
Npcs.getLoaded(Npcs.getNameFilter("Chicken", "Skeleton").and(Npcs.getVisibleFilter()))|sortByDistance().limit(0, 3).random()
Query API
Code:
Npcs.newQuery().visible().names("Chicken", "Skeleton").results()|sortByDistance().limit(0, 3).random()

These more complex actions are known to reduce ban-rates by adding a touch of personalization and by making it so that scripts aren't as predictable (and that's why I strongly encourage their usage)
 
Last edited:
Joined
Jun 21, 2014
Messages
350
Code:
Npcs.newQuery().visible().names("Chicken", "Skeleton").results()|sortByDistance().subList(0, 3).random()
Doesn't look like .subList() is there any more, it gives me a no such method error or something like that.
 
Top