squattingmonk/nasher

Erf project does not import correctly

Closed this issue · 1 comments

I have this target

[Target]
name = "erf"
description = "Erfs for this mod"
file = "erf/scripts.erf"
include = "../../scripts/ultima_schedules.erf"

When I import the resulting erf, the scripts don't show up in the module. But if import the ultima_schedules.erf they do.

what's happening here?

It looks like you're misunderstanding how the includes work. Modules, erfs, and haks are all Encapsulated Resource Files (ERFs). When one of these files is extracted, you are left with the resources that make up the module (or hak, or whatever). These may be plain text (in the case of scripts) or they may be in BioWare's Generic File Format (GFF). GFF files include the module (module.ifo files), areas (*.are files), and so on. Since GFF is a binary format, it needs to be converted into a text format that Git can recognize; nasher defaults to using JSON for this. All of these text files are then sorted into folders in your project so you can make sense of them, track them with Git, etc. The directory structure we store them in is called the source tree.

When you unpack a module, erf, or hak, nasher does the following:

  1. Unpacks the ERF file into a temporary folder. This yields a bunch of GFFs and scripts.
  2. Copies any scripts or other text files from the temp directory into your source tree.
  3. Converts any GFF files in the temp directory into JSON format and places them in the source tree.

When you pack a file, nasher does the reverse:

  1. Converts any JSON files in the source tree into GFF format and places them into a temporary directory.
  2. Copies any scripts or other text files from the source tree into the temp directory.
  3. Compiles all scripts in the temp directory.
  4. Packs all files in the temp directory into an ERF (which may be a module, hak, or erf).

In your nasher.cfg file, the file field is the ERF file that is being packed or unpacked. The include and exclude fields are used to define the source tree. This is why they take a glob format and can be repeated. All files in the source tree should be JSON versions of GFF files or script sources (NSS files). You can't include an erf file, because erf files cannot be packed into other erf files.

A proper target setup should list the files that nasher should look for which need to be packed into the final module, erf, or hak. For example:

[Target]
name = "erf"
file = "scripts.erf"           # The name of the output file
include = "src/scripts/*.nss"  # Pattern to match all script in src/scripts
"*.nss" = "src/scripts"        # Location to put any new scripts when unpacking

For first-time setup, you need to unpack the contents of ultima_schedules.erf into the source tree so you have something to work with. Move it to the package root (the directory containing nasher.cfg) and run the following:

nasher unpack erf --file:ultima_schedules.erf --removeDeleted:false

After that, you can just nasher pack/unpack erf as normal.