Tutorial Adding to the Web from a file

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

  1. Aidden

    Aidden The better executive

    Joined:
    Dec 3, 2013
    Messages:
    3,504
    Likes Received:
    728
    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. Geashaw

    Joined:
    Jan 8, 2015
    Messages:
    1,416
    Likes Received:
    249
    @Aidden Could you elaborate the use of adding web?
     
  3. Aidden

    Aidden The better executive

    Joined:
    Dec 3, 2013
    Messages:
    3,504
    Likes Received:
    728
    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. SlashnHax

    Joined:
    Dec 10, 2014
    Messages:
    2,963
    Likes Received:
    874
    What about the edges?
     
  5. Aidden

    Aidden The better executive

    Joined:
    Dec 3, 2013
    Messages:
    3,504
    Likes Received:
    728
    What do you mean?
     
  6. SlashnHax

    Joined:
    Dec 10, 2014
    Messages:
    2,963
    Likes Received:
    874
    Are the edges added as well? I guess they would be if the vertex itself holds the edge data.
     
  7. Aidden

    Aidden The better executive

    Joined:
    Dec 3, 2013
    Messages:
    3,504
    Likes Received:
    728
    Yeah, everything is added.
     
  8. SlashnHax

    Joined:
    Dec 10, 2014
    Messages:
    2,963
    Likes Received:
    874
    Hmmm, makes sense. In the case of two webs overlapping, but not connected, what happens?
     
  9. Aidden

    Aidden The better executive

    Joined:
    Dec 3, 2013
    Messages:
    3,504
    Likes Received:
    728
    I'm not sure. @Cloud
     
  10. Cloud

    Joined:
    Jul 28, 2013
    Messages:
    2,575
    Likes Received:
    930
    If they're not connected only one or the other will be used likely depending on which contains a closer vertex.
     
  11. Hazard

    Joined:
    Apr 18, 2015
    Messages:
    394
    Likes Received:
    84
    #11 Hazard, Jun 20, 2015
    Last edited: Jun 20, 2015
  12. muttaclien

    Joined:
    Jul 18, 2015
    Messages:
    6
    Likes Received:
    0
    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. Aidden

    Aidden The better executive

    Joined:
    Dec 3, 2013
    Messages:
    3,504
    Likes Received:
    728
    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. DarkenedSoul

    Joined:
    Oct 2, 2015
    Messages:
    31
    Likes Received:
    5
    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. Aidden

    Aidden The better executive

    Joined:
    Dec 3, 2013
    Messages:
    3,504
    Likes Received:
    728
    why would you need that? it's not for human reading lol
     
  16. DarkenedSoul

    Joined:
    Oct 2, 2015
    Messages:
    31
    Likes Received:
    5
    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. Aidden

    Aidden The better executive

    Joined:
    Dec 3, 2013
    Messages:
    3,504
    Likes Received:
    728
    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...