Add console variables (CVars)
under review
V
Victor Reis (xalalau)
Console variables can be perfectly emulated with a console command that changes the value of a global variable read by various functions. However, a command variable:
- adds the convenience of other modders knowing exactly how to get its value (going for the cvar name and not for some random Lua variable in the code);
- lessens the chance of name conflicts in the global Lua environment (since all these indentifications are abstracted by the API) (Modders tend to be much more careful with cvar names than with internal variables btw); and
- ensures that configurable values are exposed for all addons (which I'm sure will be a problem for nanos due to the way addons work - requiring Package.Export).
Preview:
AddConVar( "hi", "1") -- Accepts strings and numbers
local cachedCvar = GetConVar("hi")
print(cachedCvar:GetString())
An old implementation I made:
GTNardy
under review