Importing .yml

Hi there,

I’m having a devil of a time trying to load my script files after I compile the project. The first problem I run into is the fact that the asset manager cannot load .yml files. That isn’t an issue as I simply solved it by using the file input stream.

My problem seems to come after compiling the project. I am not sure if I am referencing the assets jar correctly or if it is somehow making the scripts unreachable by placing them in the .jar.

I’m sure the solution isn’t so far way from where I am.

Here is my culprit method

[java] Yaml yaml = new Yaml();
String filePath = “Assets/Scripts/”;
stateManager.getApplication().getAssetManager().registerLocator(filePath, FileLocator.class);
File file = new File(filePath + script + “.yml”);
Object obj;

  try {
      
      FileInputStream f = new FileInputStream(file);
      obj               = yaml.load(f);
      map               = (LinkedHashMap) obj;
      
  }
  
  catch (FileNotFoundException e) {
  
      System.out.println(e);
      
  }[/java] 

I just need to be able to find my scripts after I build it.

You won’t, especially not on other operating systems because they are in a jar (or other binary) file. The AssetManager can load “yml” files just fine, you just have to tell it how. Search the forum, theres been some examples on how to load plain text files through the assetmanager.

Assetmanager locate might be all you need.