1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Resource Cache Pathing

Discussion in 'Tutorials & Resources' started by Bing Bong, Feb 25, 2024.

  1. Bing Bong

    Bing Bong Bot Author

    Joined:
    Jan 29, 2016
    Messages:
    1,083
    Likes Received:
    103
    I've noticed alot of people having issues with their bots recently and I thought I would share this to assist new developers coming into the scene.

    Tutorial - Tutorial - Understanding Runemate's Pathing Systems, and Utilizing Them DON'T USE THIS

    When you're making a webPath you would usually do something like

    Code (Text):
    1.  
    2. WebPath path = WebPathRequest.builder().setDestination(x).build();
    3. if (path != null) { path.step(true);
    4.  
    You should ideally be using this kind of format.
    Code (Text):
    1.  
    2.  
    3.  private static final Map<String, WebPath> pathCache = new HashMap<>();
    4.  
    5.     public static WebPath getPathDestination(Locatable destination, boolean usingTeleports) {
    6.         String key = destination.toString() + usingTeleports;
    7.         WebPath cachedPath = pathCache.get(key);
    8.  
    9.         if (cachedPath == null) {
    10.             cachedPath = WebPathRequest.builder()
    11.                 .setDestination(destination)
    12.                 .setUsingTeleports(usingTeleports)
    13.                 .build();
    14.             pathCache.put(key, cachedPath);
    15.         }
    16.         return cachedPath;
    17.     }
    18.  
    If you're wanting to use it for Landmarks, you can change this to this format
    Code (Text):
    1.  
    2.     public static WebPath getPathLandmark(Landmark landmark, boolean usingTeleports) {
    3.         String key = landmark.toString() + usingTeleports;
    4.         WebPath cachedPath = pathCache.get(key);
    5.  
    6.         if (cachedPath == null) {
    7.             cachedPath = WebPathRequest.builder()
    8.                 .setLandmark(landmark)
    9.                 .setUsingTeleports(usingTeleports)
    10.                 .build();
    11.             pathCache.put(key, cachedPath);
    12.         }
    13.         return cachedPath;
    14.     }
    15.  
    To call the path, you would now do

    Code (Text):
    1. WebPath path = getPathDestination(X,Y,Z, true/false);
     
    #1 Bing Bong, Feb 25, 2024
    Last edited: Feb 25, 2024

Share This Page

Loading...