Tutorial Adding to the Web from a file

Discussion in 'Tutorials & Resources' started by Aidden, Jan 27, 2015.

  1. Hey guys! Just a quick tutorial on adding to the web from a file.
    First, use one of the Web extender scripts bots on the sdn to create a new web.
    Once you've saved the file it will be stored somewhere on your harddrive. My extender stores it in the RuneMate/bots/MaxiWebExtender directory.

    You will need to package this file with your script bot and add it in the manifest as a resource like so:
    Code (Text):
    1.  
    2. <resources>
    3.         <resource>com/runemate/maxiscripts/looping/fisher/karamja_f2p_surface.bin</resource>
    4.     </resources>
    5.  
    You then need to load the resource in your script bot and add it to the web. Here is my method for doing so:

    Code (Text):
    1.  
    2.     public void addToWeb(String filename) {
    3.         FileWeb fweb = null;
    4.         InputStream is = MaxiFisher.class.getResourceAsStream(filename);
    5.         if (is != null) {
    6.             try {
    7.                 byte[] bytes = IOUtils.readFully(is, -1, true);
    8.                 if (bytes != null) {
    9.                     fweb = FileWeb.fromByteArray(bytes);
    10.                 }
    11.             } catch (ClassNotFoundException | IOException e) {
    12.                 // TODO Auto-generated catch block
    13.                 e.printStackTrace();
    14.             }
    15.         }
    16.         else {
    17.             System.out.println("Null inputstream");
    18.         }
    19.         if (fweb != null) {
    20.             web.addVertices(fweb.getVertices());
    21.         }
    22.         else {
    23.             System.out.println("Null fileweb");
    24.         }
    25.     }
    26.  
    And here's an example of me adding my karamja web to my script bot:
    Code (Text):
    1.  
    2. Web web = new Web();
    3. web.addVertices(Traversal.getDefaultWeb().getVertices());
    4. addToWeb("/com/runemate/maxiscripts/looping/fisher/karamja_f2p_surface.bin");
    5.  
    I have created a web object and then copied the default webs vertices into it because if you add to the default web directly, it stays added even if you swap scripts bots. I then just call the addToWeb() method specifying the absolute path of my resource.
     
  2. @Aidden Could you elaborate the use of adding web?
     
  3. Why you would do it? Certain areas aren't mapped so you need to map them if they're going to be used in you're script bot
     
  4. What about the edges?
     
  5. What do you mean?
     
  6. Are the edges added as well? I guess they would be if the vertex itself holds the edge data.
     
  7. Yeah, everything is added.
     
  8. Hmmm, makes sense. In the case of two webs overlapping, but not connected, what happens?
     
  9. I'm not sure. @Cloud
     
  10. If they're not connected only one or the other will be used likely depending on which contains a closer vertex.
     
  11. #11 Hazard, Jun 20, 2015
    Last edited: Jun 20, 2015
  12. Hey, any idea how to do this after shift of local default webwalking to cloud? Traversal.getDefaultWeb().getVertices() Doesn't seem to work now. Alternatively, would be super cool if someone can dump some custom web data.

    Thanks!
     
  13. YEah there's no way to add to the existing web now, so you need to build a web from scratch without importing the default web with my tool. And then you need to use logic to decide whether to use the local web or the default web.
     
  14. Another other guide of what the inside of that bin looks like?, Would like to web some areas and don't know how it's stored
     
  15. why would you need that? it's not for human reading lol
     
  16. I don't understand how the web works.
    I assumed the bin was a list of tile/object links that loaded in.
    Clearly I Miss understand how this whole things works
     
  17. As the first post says, use a web extender bot to generate the .bin, which by the way should be .nav instead, cloud wants web file as .nav now. And if you want to know how the web extender does it just take a quick look at the api for the FileWeb class and the web extension tutorials by cloud.
     

Share This Page

Loading...