Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!

Difference between revisions of "cvar"

From Quake Wiki

m (Redirect to DP_QC_CVAR_STRING instead of cvar_string.)
m (Usage)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
====Syntax:====
+
''float'' '''cvar'''(''string'' name)
<code>float cvar(string name)</code>
 
  
Get the value of a named cvar. In order to get [[string]] values, you'll have to use a custom engine that supports the [[DP_QC_CVAR_STRING|cvar_string]] builtin.
+
== Usage ==
 +
Gets the value of a console variable as a number. For variables that don't store numbers or don't exist this will always return 0.
  
====Parameters:====
+
=== Parameters ===
:<code>name</code> - Name of the cvar to query.
+
*''name''
====Returns:====
+
:The name of the console variable.
:Returns the numeric value of the named cvar.
 
  
 +
=== Return ===
 +
The value of the console variable.
 +
 +
== Example ==
 +
// Get the current gravity
 +
float gravity = cvar("sv_gravity");
  
 
[[Category:QuakeC Function]]
 
[[Category:QuakeC Function]]

Latest revision as of 17:43, 1 August 2023

float cvar(string name)

Usage[edit]

Gets the value of a console variable as a number. For variables that don't store numbers or don't exist this will always return 0.

Parameters[edit]

  • name
The name of the console variable.

Return[edit]

The value of the console variable.

Example[edit]

// Get the current gravity
float gravity = cvar("sv_gravity");