Nuclide
Software Development Kit for id Tech
Constants

Constants macro loader. More...

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...
 
bool Constants_Add (string constantName, string constantValue)
 Call to add a custom constant with a specific value. More...
 

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:

// render modes
@ RM_ADDITIVE
Definition: NSRenderableEntity.h:49
@ RM_ADDFRAC
Definition: NSRenderableEntity.h:51
@ RM_WORLDGLOW
Definition: NSRenderableEntity.h:52
@ RM_COLOR
Definition: NSRenderableEntity.h:45
@ RM_NORMAL
Definition: NSRenderableEntity.h:44
@ RM_FULLBRIGHT
Definition: NSRenderableEntity.h:50
@ RM_GLOW
Definition: NSRenderableEntity.h:47
@ RM_DONTRENDER
Definition: NSRenderableEntity.h:53
@ RM_TEXTURE
Definition: NSRenderableEntity.h:46
@ RM_SOLID
Definition: NSRenderableEntity.h:48

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:

"rendermode" "$RM_ADDITIVE"

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_Add()

bool Constants_Add ( string  constantName,
string  constantValue 
)

Call to add a custom constant with a specific value.

Parameters
constantNameName of the constant to set.
constantValueThe value to set the constant as.
Returns
Will return true upon success. Will return false when out of memory.

◆ 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.