FMTK SDK API

Defines

FMTKSDK_HPP
FMTK_VERSION

A c-style string literal containing the dot separated version number.

FMTK_VERSION_MAJOR

An integer literal containing the major component of the version number.

FMTK_VERSION_MINOR

An integer literal containing the minor component of the version number.

FMTK_VERSION_PATCH

An integer literal containing the patch component of the version number.

FMTK_VERSION_TWEAK

An integer literal containing the tweak component of the version number.

FMTKAPI
REGISTER_MOD(class_name)

Generates the necessary functions for the mod to be loaded by FMTK and initialize the fmtk global variable. This macro should only be used once per dll. This macro must appear after the mod class has been defined.

Parameters:
  • class_name – The fully qualified name of the class implementing FMTKMod. There should only be one class implementing FMTKMod per dll.

Enums

enum class LogLevel

Log levels available for use with Log.

Values:

enumerator TRACE

This is a message for an FMTK developer. Exclude it from release builds.

enumerator DEBUG

This is a message for a mod developer.

enumerator INFO

This is a message for a user that everything is fine and no action is necessary.

enumerator WARN

This is a message for a user that something may be wrong but no action is necessary.

enumerator ERR

This is a message for a user that something is wrong but no action is necessary. A recoverable error.

enumerator CRITICAL

This is a message for a user that something is wrong and action is necessary. An unrecoverable error.

Functions

FMTKAPI const FMTKVersion * GetFMTKVersion ()

Get a pointer to the version of the FMTKSDK used to build the mod.

Returns:

A pointer to an FMTKVersion struct owned by the mod. This should not be freed.

Variables

const FMTKVersion fmtkVersion
const FMTKApi *fmtk

A pointer to an FMTKApi struct owned by FMTK and automatically initialized when the mod is registered. This should not be freed.

struct FMTKVersion

This structure contains the values of the version macros of FMTK SDK used to build the mod.

Public Members

unsigned int major = FMTK_VERSION_MAJOR

The major version.

unsigned int minor = FMTK_VERSION_MINOR

The minor version.

unsigned int patch = FMTK_VERSION_PATCH

The patch version.

unsigned int tweak = FMTK_VERSION_TWEAK

The tweak version.

class FMTKApi

This structure contains pointers to FMTK functions that should be filled in when the mod is loaded.

Public Members

const char *(*GetModsDirectoryPath)()

Get the mods directory path.

Get the absolute path of the mods directory as a c-style string.

Return:

A c-style string containing the absolute path of the mods directory.

float *(*GetPlayerPosition)()

Get the players position.

Get the players position as a 3 element float array.

Return:

A pointer to a 3 element float array containing the XZY components of the player’s position. Will be null if the players position cannot be obtained. This pointer is owned by FMTK and should not be freed.

bool (*RunCommand)(const char *cmd)

Run a command string.

Run a command string.

Param cmd:

A c-style string containing the command string. Owned by the caller.

Return:

A bool that is true if the command ran successfully and false if it failed.

void (*RegisterCommand)(const char *name, bool (*callback)(int argc, const char **argv))

Register a command.

Register a command.

Param name:

A c-style string containing the command name. The abbreviated version of the command name will be generated from the capital letters taken in left to right order.

Param callback:

A pointer to a callback function to be run when the command is invoked.

void (*UnregisterCommand)(const char *name)

Unregister a command.

Remove a previously registered command callback.

Param name:

A c-style string containing the command name. Both the long form and short form are accepted.

void (*Log)(LogLevel level, const char *source, const char *msg)

Submit a log message.

Submit a log message to FMTK to be output to the console and written to the log file as applicable.

Param level:

The severity of the incident being logged.

Param source:

A c-style string containing the name of the event’s source. This should be the name of the mod calling the function.

Param msg:

A c-style string containing the message to be logged.

void (*Alias)(const char *originalPath, const char *newPath)

Alias a path.

Instruct fuel to open the newPath whenever it tries to open originalPath.

Param originalPath:

The original path relative to FUEL’s working directory. Case insensitive.

Param newPath:

The new path relative to FUEL’s working directory. Case insensitive.

void (*Unalias)(const char *originalPath)

Unalias a path.

Instruct fuel to open the originalPath whenever it tries to open originalPath undoing a previous Alias call.

Param originalPath:

The original path relative to FUEL’s working directory. Case insensitive.

class FMTKMod

The FMTKMod base class all mods inherit.

Public Functions

inline virtual void Initialize()

Initialize Hook.

This function is called before the game’s WinMain entry point. At this point the ScriptManager is unavailable so calls to command functions will fail. This will always be the first hook to run.

inline virtual void Tick()

Tick Hook.

This function is called once per execution of the game’s CoreMainLoop function.

inline virtual void ScriptManagerInitialize()

ScriptManagerInitialize Hook.

This function is called once the ScriptManager is initialized. This is the first legal place to call the register command function. None of the FUEL commands have been registered yet so RunCommand with them will fail.

inline virtual void Shutdown()

Shutdown Hook.

This function is called before the FMTK dll is unloaded. This will always be the last hook to run.