Resource Converting old FileWeb to new SerializableWeb & adding vertices

Discussion in 'Tutorials & Resources' started by Party, Apr 18, 2016.

  1. Hey guys.

    The following "bot" will convert an old pre-Spectre "FileWeb" into a Spectre-compatible SerializableWeb, with the option to add vertices.

    There is no UI of any kind, just code, so you'll probably have to do some tweaking to get it to work but the process is fairly straight-forward and the comments should guide you.

    Credit to @SlashnHax for showing me the conversion and @Cloud for his tutorial on web expansion: Tutorial - [Series] Expanding The Navigation Web - Basic Objects (Agility Shortcuts) | Community | RuneMate

    Main class: convertFileWeb.java
    Code (Javascript):
    1. package com.pBots.web;
    2.  
    3. import com.runemate.game.api.hybrid.local.Skill;
    4. import com.runemate.game.api.hybrid.location.Coordinate;
    5. import com.runemate.game.api.hybrid.location.navigation.web.SerializableWeb;
    6. import com.runemate.game.api.hybrid.location.navigation.web.default_webs.FileWeb;
    7. import com.runemate.game.api.hybrid.location.navigation.web.requirements.Requirement;
    8. import com.runemate.game.api.hybrid.location.navigation.web.vertex_types.objects.BasicObjectVertex;
    9. import com.runemate.game.api.hybrid.util.Resources;
    10. import com.runemate.game.api.hybrid.util.Usable;
    11. import com.runemate.game.api.script.framework.task.TaskScript;
    12.  
    13. import java.io.IOException;
    14. import java.nio.file.Files;
    15. import java.nio.file.Path;
    16. import java.nio.file.Paths;
    17. import java.util.Collection;
    18. import java.util.Collections;
    19.  
    20.  
    21. public class convertFileWeb extends TaskScript {
    22.  
    23.     //If you plan on adding vertices, expand on the following as necessary
    24.     private Coordinate objectPos = new Coordinate(0, 0, 0);
    25.     private Coordinate landingPos = new Coordinate(0, 0, 0);
    26.  
    27.     //If the object has a requirement, declare it here
    28.     final Usable requirement = new Usable() {
    29.         @Override
    30.         public boolean isUsable() {
    31.             return Skill.AGILITY.getCurrentLevel() >= 21;
    32.         }
    33.  
    34.     };
    35.  
    36.     //Declare the vertex/vertices
    37.     final BasicObjectVertex object = new BasicObjectVertex(objectPos, "Object name", "Action", (Collection<Requirement>) requirement); //If no requirement then Collections.emptyList()
    38.  
    39.  
    40.     //Declare your new web
    41.     private SerializableWeb webName;
    42.  
    43.     public void onStart(String... args) {
    44.         try {
    45.             webName = new SerializableWeb();
    46.             webName.addVertices(FileWeb.fromByteArray(Resources.getAsByteArray("path/to/old/web.nav")).getVertices());
    47.  
    48.             //Connect the vertices
    49.             webName.getVertexNearestTo(objectPos).addBidirectionalEdge(object);
    50.  
    51.             //Save your new web
    52.             Path path = Paths.get("path\\to\\output.nav");
    53.             Files.createFile(path);
    54.             Files.write(path, webName.serialize());
    55.  
    56.         } catch (IOException e) {
    57.             e.printStackTrace();
    58.         }
    59.     }
    60. }
    61.  

    Manifest: convertFileWeb.manifest.xml
    HTML:
    1. <manifest>
    2.     <main-class>com.pBots.web.convertOldVertices</main-class>
    3.     <name>ConvertOldWeb</name>
    4.     <tag-line>Convert of FileWeb to new SeriazableWeb</tag-line><!--Max of 50 chars-->
    5.     <description>EConvert of FileWeb to new SeriazableWeb, and add new vertices</description><!--Max of 110 chars-->
    6.     <version>1</version>
    7.     <compatibility>
    8.         <game>OSRS</game>
    9.         <game>RS3</game>
    10.     </compatibility>
    11.     <categories>
    12.         <category>DEVELOPER_TOOLS</category>
    13.     </categories>
    14.     <!--Required to publish on the bot store-->
    15.     <internal-id>ConvertOldWeb</internal-id>
    16.     <!--The rest are optional-->
    17.     <open-source>true</open-source>
    18.     <hidden>false</hidden> <!--If you need to hide it from the bot store for maintenance-->
    19.     <access>public</access>
    20.     <tags>
    21.         <tag>web</tag>
    22.     </tags>
    23.  
    24.     <resources>
    25.         <resource>reference/to/old/web.nav</resource>
    26.     </resources>
    27. </manifest>
     

    Attached Files:

    Derk likes this.
  2. Make a basic UI for it and publish it on the Bot Store fool. <3
     
  3. Yayayaya I just did it in the 15 minutes before I passed out last night, I'll get on it later :D
     
    Seathe likes this.

Share This Page

Loading...