ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


functions:a_getcvarfixed

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
functions:a_getcvarfixed [2017/03/13 18:46] – created korshunfunctions:a_getcvarfixed [2017/06/16 13:25] (current) korshun
Line 1: Line 1:
-#REDIRECT GetCVarFixed+====== a_GetCVarFixed ====== 
 +{{tag>zdoom cvar}} 
 +''fixed a_GetCVarFixed(str name)'' 
 + 
 +<note important>This function is called ''a_GetCVarFixed()'' because it conflicts with [[:GDCC]]'s unrelated ''GetCVarFixed()''.</note> 
 + 
 +===== Description ===== 
 +Returns the value of an int or float CVar as a fixed-point number. 
 + 
 +Returns 0 if the CVar doesn't exist or is not a number. 
 + 
 +The function works by calling [[zdoom>GetCVarString]] and parsing the text with [[atof]]. 
 + 
 +===== Examples ===== 
 +<code> 
 +int mul = a_GetCVarFixed("mymod_multiplier"); // declared as float in CVARINFO 
 +int value = FixedMul(x, mul); 
 +</code> 
 + 
 +From [[UpdateCursor]] source: 
 +<code> 
 +int sensitivity = a_GetCVarFixed("mouse_sensitivity"); 
 +int speedX = FixedDiv(CursorSpeedX, FixedMul(a_GetCVarFixed("m_yaw"), sensitivity)); 
 +int speedY = FixedDiv(CursorSpeedY, FixedMul(a_GetCVarFixed("m_pitch"), sensitivity)); 
 +</code> 
 + 
 +===== See also ===== 
 +  * [[GetUserCVarFixed]]
functions/a_getcvarfixed.1489423592.txt.gz · Last modified: 2017/03/13 18:46 by korshun