ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


getcvarfixed

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
getcvarfixed [2019/04/22 22:34] korshungetcvarfixed [2019/08/26 04:30] (current) korshun
Line 1: Line 1:
 ====== GetCVarFixed ====== ====== GetCVarFixed ======
  
-ZDoom provides [[zdoom>GetCVar]] for ints and [[zdoom>GetCVarString]] for strings, but doesn't provide a way to retrieve the value of ''float'' CVars. ACSUtils implements ''GetCVarFixed'' by calling [[zdoom>GetCVarString]] to retrieve the value of the CVar as a string, and parsing it with [[number parsing|ACSUtils number parsing functions]].+ZDoom provides [[zdoom>GetCVar]] for ints and [[zdoom>GetCVarString]] for strings, but doesn't provide a way to retrieve the value of ''float'' CVars. ACSUtils implements ''GetCVarFixed'' by calling [[zdoom>GetCVarString]] to retrieve the value of the CVar as a string, and parsing it with [[number_parsing|atof]].
  
  
-<note important>If the CVar's value is outside the range of fixed-point numbers, the functions return ''0.0''.</note>+<note important>If the CVar's value is outside the range of fixed-point numbers, the result is clamped to ''-32768.0''..''32767.99997'' range.</note>
  
-<note important>The functions names begin with ''a_'' because [[GDCC]] defines its own broken ''GetCVarFixed'', which causes a compilation error if another function named ''GetCVarFixed'' exists.</note>+<note important>The function names begin with ''a_'' because [[GDCC]] defines its own broken ''GetCVarFixed'', which causes a compilation error if another function named ''GetCVarFixed'' exists.</note> 
 + 
 +<note tip>If you're not using [[GDCC]], you can remove the ''a_'' prefix by adding the following to your code: 
 +<code> 
 +function GetCVarFixed(str name) 
 +
 +    return a_GetCVarFixed(name); 
 +
 + 
 +function GetUserCVarFixed(int player, str name) 
 +
 +    return a_GetUserCVarFixed(player, name); 
 +
 +</code> 
 +</note>
  
 ===== Functions ===== ===== Functions =====
Line 15: Line 29:
 Analogous to [[zdoom>GetCVar]] and [[zdoom>GetCVarString]]. Analogous to [[zdoom>GetCVar]] and [[zdoom>GetCVarString]].
  
-===== GetUserCVarFixed =====+==== GetUserCVarFixed ====
 ''fixed a_GetUserCVarFixed(int player, str name)'' ''fixed a_GetUserCVarFixed(int player, str name)''
  
getcvarfixed.1555961684.txt.gz · Last modified: 2019/04/22 22:34 by korshun