SCORINFO/IfCVar

From Zandronum Wiki
This article documents a SCORINFO margin command which is only available in development builds of Zandronum 3.2 and newer.

IfCVar (<cvarname> <operator> <value>) (development version 3.2-alpha and above only)

Usage

Executes the following sub-block if the specified console variable (CVar)'s value satisfies the condition that's given. If the condition fails, then the "else" block, if one exists, is executed instead.

Parameters

  • cvarname: The name of the CVar.
  • operator: What operator to use in the comparison. The following operators are supported:
    • ==: both values are equal to each other.
    • !=: the values aren't equal to each other.
    • >: the CVar's value is greater than the other value.
    • >=: the CVar's value is greater than or equal to the other value.
    • <: the CVar's value is less than the other value.
    • <=: the CVar's value is less than or equal to the other value.
  • value: The value to compare against. The data type must be the same as the CVar's.

Examples

On the intermission screen in online games, a CVar like "cl_intermissiontimer" can be used to decide if the amount of time left before entering the next level automatically is shown or not.

IfIntermission( true )
{
    IfOnlineGame( true )
    {
        IfCVar( cl_intermissiontimer == true )
        {
            DrawString( value = "Entering " + nextlevellump + ": " + nextlevelname + " in " + intermissiontimeleft + " second(s)", textcolor = "Green" )
        }
    }
}

See also