Tutorial Using The Results API

Discussion in 'Tutorials & Resources' started by Cloud, Aug 2, 2014.

  1. 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 (Text):
    1.  
    2. Npcs.getLoaded("Chicken", "Skeleton")|nearest()
    3.  
    Query API
    Code (Text):
    1.  
    2. Npcs.newQuery().names("Chicken", "Skeleton").results()|nearest()
    3.  
    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 (Text):
    1.  
    2. Npcs.getLoaded(Npcs.getNameFilter("Chicken", "Skeleton").and(Npcs.getVisibleFilter()))|sortByDistance().limit(0, 3).random()
    3.  
    Query API
    Code (Text):
    1.  
    2. Npcs.newQuery().visible().names("Chicken", "Skeleton").results()|sortByDistance().limit(0, 3).random()
    3.  
    These more complex actions are known to reduce ban-rates by adding a touch of personalization and by making it so that scripts bots aren't as predictable (and that's why I strongly encourage their usage)
     
    #1 Cloud, Aug 2, 2014
    Last edited: Jan 17, 2015
    Furor likes this.
  2. Doesn't look like .subList() is there any more, it gives me a no such method error or something like that.
     
  3. Instead you should use the limit method.
     

Share This Page

Loading...