Jump to content

Using Resources folder


Recommended Posts

Posted

Hey guys,

 

I've had quite a few scripters attempt to use the resources folder to load stuff without having to download them manually, so I figured I'd write a quick tutorial.

 

(I've put this in the scripter section because I'd rather not have new scripters throwing random shit into that folder. Please limit it to image/text only).

 

RESOURCES Folder location:

 

For a script, put the resources folder in the root of the script module (I think root of the git repo works too if you want to use global resources).

 

IE:

 

dreamscripts

--> DreamChopper

     --> resources

          --> ValkyrIsANoob.jpg

 

Accessing resource from your script:

 

Here's a quick test script that I created and submitted to SDN to check that it works: (You can pull out the code...)

package test;

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import java.io.*;

/**
 * Created by ericthecmh on 8/26/15.
 */
@ScriptManifest(version = 1.0, author = "Ericthecmh", logo = "", info = "Amaze", name = "Llama")
public class Llama extends Script {

    private BufferedReader br;

    @Override
    public void onStart() {
        br = new BufferedReader(new InputStreamReader(this.getClass().getResourceAsStream("/resources/LLAMAS.DAT")));
    }

    @Override
    public int onLoop() throws InterruptedException {
        try {
            String s = br.readLine();
            if (s != null)
                log(s);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return 1000;
    }z
}

I TESTED LOCALLY AND IT DOESN'T WORK???

 

Make sure that when you build the local jar, it contains the resources folder in the root of the jar:

 

DreamChopper.jar

--> resources/

     --> LLAMAS.DAT

--> org

     --> dreamscripts

          --> chopper

  • Like 8
  • 2 years later...
Posted

I have followed every step in this tutorial and have verified the resource file is in the right spot on the jar and have tried this with a non osbot jar and everything works, but I cannot get this working in OSBOT at all. My guess is there has been security permissions that have changed this this post was made. Can anyone verify this still works because I have tried everything.

Posted
18 minutes ago, battleguard said:

I have followed every step in this tutorial and have verified the resource file is in the right spot on the jar and have tried this with a non osbot jar and everything works, but I cannot get this working in OSBOT at all. My guess is there has been security permissions that have changed this this post was made. Can anyone verify this still works because I have tried everything.

The new directory is OSBot\data. You can get this directory in your script by doing getDirectoryData() and then concatenate the file name onto that.

  • Like 1
Posted (edited)
1 hour ago, d0zza said:

The new directory is OSBot\data. You can get this directory in your script by doing getDirectoryData() and then concatenate the file name onto that.

the problem with the Osbot\data folder is I want to be able to bake resources into my jar so I do not have to download all the files off the web and put the cached version into the osbot\data folder. For example if I had images for my paint it would be nice to just put them in my resources folder instead of having to store them online and then download them when I want to run the script. Sure once I run it once I could cache them in the users osbot\data folder but I would rather not have to do that.

 

Also if that is the case now that OSBOT/data is supposed to be used for now on hopefully one of the mods can remove this sticky it might save some other scripter a couple hours of headache.

Edited by battleguard
Posted
34 minutes ago, battleguard said:

the problem with the Osbot\data folder is I want to be able to bake resources into my jar so I do not have to download all the files off the web and put the cached version into the osbot\data folder. For example if I had images for my paint it would be nice to just put them in my resources folder instead of having to store them online and then download them when I want to run the script. Sure once I run it once I could cache them in the users osbot\data folder but I would rather not have to do that.

 

Also if that is the case now that OSBOT/data is supposed to be used for now on hopefully one of the mods can remove this sticky it might save some other scripter a couple hours of headache.

Yeah just put the images into your Osbot\data folder and you'll be able to use them.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...