- Joined
- Dec 3, 2013
- Messages
- 7,032
- Thread Author
- #1
Hey guys! Just a quick tutorial on adding to the web from a file.
First, use one of the Web extender scripts 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 and add it in the manifest as a resource like so:
You then need to load the resource in your script and add it to the web. Here is my method for doing so:
And here's an example of me adding my karamja web to my script:
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. I then just call the addToWeb() method specifying the absolute path of my resource.
First, use one of the Web extender scripts 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 and add it in the manifest as a resource like so:
Code:
<resources>
<resource>com/runemate/maxiscripts/looping/fisher/karamja_f2p_surface.bin</resource>
</resources>
You then need to load the resource in your script and add it to the web. Here is my method for doing so:
Code:
public void addToWeb(String filename) {
FileWeb fweb = null;
InputStream is = MaxiFisher.class.getResourceAsStream(filename);
if (is != null) {
try {
byte[] bytes = IOUtils.readFully(is, -1, true);
if (bytes != null) {
fweb = FileWeb.fromByteArray(bytes);
}
} catch (ClassNotFoundException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else {
System.out.println("Null inputstream");
}
if (fweb != null) {
web.addVertices(fweb.getVertices());
}
else {
System.out.println("Null fileweb");
}
}
And here's an example of me adding my karamja web to my script:
Code:
Web web = new Web();
web.addVertices(Traversal.getDefaultWeb().getVertices());
addToWeb("/com/runemate/maxiscripts/looping/fisher/karamja_f2p_surface.bin");