Nuclide
Software Development Kit for id Tech
cloader.h File Reference

Constants macro loader. More...

Go to the source code of this file.

Functions

void Constants_Init (void)
 Called upon game init internally to populate our look-up table. More...
 
string Constants_LookUp (string constName, string returnValue)
 Look up a name and retrieve its value. More...
 

Variables

var hashtable g_hashConstants
 

Detailed Description

Constants macro loader.

Scripters and level designers are able to define parameters through the use of name-based lookups, so they can change them later in one convenient place.

In the game directory, they are defined within scripts/constants.txt. An example file looks like this:

// weapon constants
WEAPON_NONE 0
WEAPON_KNIFE 1
WEAPON_POTATO 2

Within EntityDefs files, you will then be able to set a given key to the value of one of the defined constants by prefixing the name with a $ symbol. That would look something like this:

"weapon" "$WEAPON_POTATO"

The same applies to data read within level files and most routines related to parsing key/value pairs, so it is not limited to usage within EntityDef.

Function Documentation

◆ Constants_Init()

void Constants_Init ( void  )

Called upon game init internally to populate our look-up table.

◆ Constants_LookUp()

string Constants_LookUp ( string  constName,
string  returnValue 
)

Look up a name and retrieve its value.

Parameters
constNameName of the constant to look up.
returnValueThe value to return if constName is not defined.
Returns
The value of the named constant. Will return returnValue if it does not exist.

Variable Documentation

◆ g_hashConstants

var hashtable g_hashConstants