Zumbs' Blog

The truth may be out there, but lies are inside your head

FOMM and FOMODs for Dummies 4: Basic FOMOD Scripting II

Posted by Zumbs on November 8, 2009

FOMM and FOMODs for Dummies

  1. Installing Mods
  2. Making FOMODS
  3. Basic FOMOD Scripting I
  4. Basic FOMOD Scripting II
  5. Working with Forms I
  6. Working with Forms II
  7. Load Order Magicks

In the previous tutorial we had a look at how to validate the users install and manipulate the ini. This tutorial will cover the subject of making a custom install script, overriding FOMMs default install script.

It is assumed that the user has chosen which options to install beforehand.

The first step is to declare a custom install function. This has the advantage of increasing the readability of our install script, which will be handy if we ever have to update the mod. The custom install function can be declared by:

public static void InstallSomeMod()
{
}

Then we must change the line

PerformBasicInstall();

to

InstallSomeMod();

This makes FOMM call our new install script when the mod is activated. It doesn’t do anything yet, though.

Installing a file

To install a specific file from the fomod archive, one can use the InstallFileFromFomod function. It takes the name of the file to install as an argument, such as

InstallFileFromFomod("somemod.esp");
InstallFileFromFomod("textures/sometexture.dds");

An esp can be activated by using SetPluginActivation, like this

SetPluginActivation("somemod.esp", true);

Renaming installation files

Sometimes you want to give the user the choice between multiple files. A classic example is a body replacer, where you want to allow the user to choose between a number of body meshes, ie. muscular/average/skinny. These will often be saved in separate folders in your fomod archive. To install a particular set of meshes, you can use the function CopyDataFile. The function can be used on multiple types of data files, as shown below:

CopyDataFile("meshes/characters/_male/upperbodymale-skinny.nif", "meshes/characters/_male/upperbody.nif");
CopyDataFile("somemod_custom_option.esp", "somemod.esp");

The first argument is the location of the file in the fomod file, the other argument is where you wish to place it in the users data folder.

Example install function

Let us assume that you have a fomod with the following files

/textures/sometexture-option1.dds
/textures/sometexture-option2.dds
/textures/sometexture-option3.dds
somemod.esp
somemod_custom_option.esp

The user can choose between the texture options and the two esps. You asked which options the user wished, and those responses are saved in the variables textureChoice and useCustomOption. The installation can be handled by the function

public static void InstallSomeMod(int textureChoice, bool useCustomOption)
{
    CopyDataFile("/textures/sometexture-option" + textureChoice + ".dds", "/textures/sometexture.dds")
    if (useCustomOption)
    {
        CopyDataFile("somemod_custom_option.esp", "somemod.esp")
    }
    else
    {
        InstallFileFromFomod("somemod.esp")
    }
    SetPluginActivation("somemod.esp", true);
}

The function must be called from the OnActivate function with the user choices as arguments:

InstallSomeMod(textureChoice, useCustomOption)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: