Creating a DXMS module

I am assuming that you already know UnrealScript before reading this tutorial - if you don't, then I would recommend learning it first - otherwise, this may well not make any sense at all.

The module itself needs to be a subclass of DXMSModule (and so, to compile, EditPackages=DXMS needs to be in UnrealTournament.ini)

The function in DXMSModule that needs to be overridden is:

function bool runCommand(string Script[20])


This function is called in each loaded module, until one returns 'true'.

Script[20] is an array of strings, for each word in the corresponding Script string in the director.
There are other variables that are set in the module before this function is called:

var float currentScriptVal;
var name currentScriptName;
var vector currentScriptVector;
var rotator currentScriptRotator;
var Director currentDirector;

The first four are all set to the corresponding values in the Director for that line, and currentDirector is a reference to the director that called the command.

A normal runCommand function will normally look something like this:

function bool runCommand(string Script[20])
{
	switch(Script[0])    
	{
	case "Effect":
		ExecuteEffect(Script);
		return true;
		break;
	case "SetSpeed":
		ExecuteSetSpeed();
		return true;
		break;
	}

	return false;
}

You can call another command in the Director, by calling:

currentDirector.CallCommand("<new command>");

This is relatively limited, however, as you cannot set anything other than the Script itself. An example of this in use can be found in DXMSCredits where the HUD is changed before the credits are run.

You can do pretty much anything from a module, apart from what I've already mentioned. Do look at the base modules for examples, and, to be perfectly honest, there's nothing stopping you from writing your own pawn or camera control module, and just leaving DXMSCamera or DXMSPawn off the Modules list.

Once you have your module completed, you will need to add it to the array of 'DXMSModules' in your first Director. There are four modules in here by default - Camera, Pawn, Effects, and Hud, but these can be removed, or swapped around. If the entry in here does not contain a string, for example, 'DXMSPawn', then it will be assumed that this is the package and the class name - so 'DXMSPawn.DXMSPawn' will be loaded. Otherwise, the module will be loaded up as it is typed in. If your scene doesn't go as expected, then do check the logs - they will tell you whether everything has loaded up properly.