Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: Loading merged CSVs  (Read 1316 times)

LazyWizard

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1365
    • View Profile
    • GitHub Profile
Loading merged CSVs
« on: September 06, 2013, 07:40:24 PM »

  • Do loadjson/csv have the same merge behavior as the game's loader? Is there a way to load the entries from a certain mod directory only?

They don't do any merging. The intention here is to enable mods to provide their own data files. If you try to load a file that's present in multiple mods, it'll grab the first one it finds.

I feel that the ability to load merged CSVs would be incredibly useful for mods. I'd love to have a method like this:
Code
loadMergedCSV(String filePath, String parentMod)
where filePath is the relative path (like "data/omnifac/ship_settings.csv"), and parentMod is the path/ID of the 'core' implementation of the CSV for proper overriding behavior.

This would be great for utility mods that add a framework that can be expanded upon by other mods. For example, other mods could add per-ship settings for the Omnifactory or register custom commands with the console mod for mod-specific debugging. Doing either of those through code creates dependencies on my mods*, whereas using a CSV would just mean that that info isn't loaded at all if the relevant mod isn't active.

*Unless you use reflection or just dump the data into SectorAPI.getPersistentData(), but neither of those are particularly elegant.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24151
    • View Profile
Re: Loading merged CSVs
« Reply #1 on: September 07, 2013, 09:23:56 AM »

Added to SettingsAPI - JSONArray getMergedSpreadhsheetDataForMod(String idColumn, String path, String masterMod).

This is kind of a pain to test, though, so... I didn't :) It *should* work but involved a bit of restructuring. Didn't break the core stuff, though, this method is basically a copy-paste-modify job.
Logged