Grimlar - Guide To .Erfs
Intro
A .erf file is an 'encapsulated resource file', and according to Bioware is one of the methods they use to pack multiple files into a single unit in the same kind of manner as if you had created a .zip, .tar or .rar file.
What it is used for is to enable a builder to export stuff from their module and pass it on to other builders without having to give them the entire module.
The other builders can then just import the .erf into their module and, theoretically at least, that's all it takes. A new item, area, placeable or whatever with next to no work.
Export Details
Its fairly straightforward:
1) Load up the module containing the stuff you want to share.
2) Go to the 'File' menu, and select the 'Export' option.
3) The 'Export Resources' wizard should open, click on 'Add Resources' to select what you want to export.
4) A new window should open, also labelled 'Export Resources', this one though can be used to select any of the resource files in your module. At the bottom you will notice three boxes for text, the middle one being labelled 'Resources of Type', this box controls what resources are shown in the main window. If you click on the arrow to the right of the box you will be shown a list of all the different resource types you can export. (Note: Most of the resources are blueprints, i.e. things you have added to the palette yourself. Also the filenames usually correspond to the resref of the resource.)
5) Select the resource you want to add in the main window and click on 'Export'. The name of the resource you selected will then be added to the list of resources to be exported. If you wish you can click on 'Add Resources' to add more resources to the list.
6) When you have finished adding resources click on 'Ok' and the wizard will ask you what filename to give the finished .erf file. It would be best to choose a filename that clearly identifies what is contained in the .erf file. (Note: .erf files are usually stored in the 'Nwn/Erf' directory.)
7) The wizard will then look for any other resource files that are required by the resources you have selected in order to work. So for example if you chose to export a conversation file, the wizard would include all the script files that appear in the 'Text Appears When' and 'Action Taken' script boxes. When it has finished this stage it will ask you to provide comments on the .erf file, for example a description of what it contains, how to use it etc.
8) At the bottom of the comments window is a check box giving you the chance to reset the factions of any creatures exported back to the parent faction it was based on. This could be useful if you've set up several custom factions since other people using your creature may well not have the same factions as you.
For example, if you export an Orc from faction 'Orc Bandits' which was originally based on the 'Hostile' faction, checking the 'Reset Factions To Parent Factions' box should export the creature as belonging to the 'Hostile' faction.
9) Click on 'Ok' when you are ready and the .erf file will be created.
Notes
The main thing you have to be careful with here is that when the wizard looks for dependencies there are some things it can't spot. For example creatures that haven't been placed in an area, but will be created when a script executes, aren't picked up as necessary for the area. Likewise script include files don't get included automatically either, similarly for scripts that are run by the 'ExecuteScript' function.
Its not that difficult to work round, there are several ways to check the file:
a) Just import the .erf file you have created back into your module, the import wizard will tell you there are conflicts with some of the resources and ask you which ones would you like to overwrite, it will then show you a list of the conflicting files, which should be everything in the .erf and you can then check the list to make sure all the necessary files were included. You can miss stuff with this method but it is quite quick.
b) Work through the scripts etc to see what has been used in such a way as to evade the export wizard. Then make sure everything is added when you build the .erf. Unfortunately this way is longwinded and prone to errors.
c) Probably the best way to do it is to create a new module, import the .erf and then see if anything fails to work. A comparison between the two modules will usually turn up the missing resource quite quickly.
Import Details
Again, its fairly straightforward:
1) Load up the module where you want the new stuff to go.
2) Go to the 'File' menu, and select the 'Import' option.
3) You should then get an 'Import' window showing you a list of all the .erf files in the 'Nwn/Erf 'directory. Choose the file you want to import and click on 'Open'.
4) You may now see an 'Import Resources' window showing you which resources would overwrite things that are already in your module. If you don't get this, don't worry, it just means there are no conflicts and you can safely move on to step 5. You can choose to import any, all or none of the conflicting files. Click on 'OK' when you have decided.
5) You are then shown the comments provided by the creator of the .erf file.
6) Click on 'Ok' to import the resources.
Notes
The only risk with this part of the process is overwriting things you already have in your module, only do this if you are absolutely sure it won't damage your module. Its usually safest to cancel the import and modify either the erf or your existing file so there are no conflicts, you can do this in several ways:
a) Copy the conflicting resources in your module so they are named differently / have different resref's, then delete the original. Finally make sure the module works as expected and then redo the import.
b) Create a temporary module and import the .erf into that. Modify the names / resref's of the imported resources and delete the originals. Then if possible make sure the changed stuff works as expected and export the .erf again, preferably to a new filename. Use the new .erf for the import into your main module.
author: Grimlar