AutoExecConfig() - List cvars by plugin code order instead of by *alphabetically?*
Help us help you
- [x] I have checked that my issue doesn't exist yet.
Is your feature request related to a problem? Please describe.
Managing and changing cvars especially when there's lot of them can be overwhelming, both to users and devs, when SouceMod (SM) decides to order the cvar by it's own way 🔢 , by listing the cvars alphabetically?
Describe the solution you'd like
I hopefully want SM by default ( or by an option, e.g AutoExecConfig(true, "xxx", bool alphabetorder = false) ) listing the cvars in the config file generated to mimic the order in the plugin code, so that the beautifully listed cvars 🏩 in the plugin config file is consistent with the plugin code.
Describe alternatives you've considered
I tried something like this as a workaround, but it looks ugly and less maintainable:
public void OnPluginStart()
{
CreateConVar(PLUGIN_FILE ... "_0_version", PLUGIN_VERSION, "Whitelist Map Configuration version", FLAG_CVAR_VERSION);
g_hEnabled = CreateConVar(PLUGIN_FILE ... "_1_enabled", "1", "Toggles plugin state (0: Off, 1: On)", FLAG_CVAR, true, 0.0, true, 1.0);
g_hConfigFile = CreateConVar(PLUGIN_FILE ... "_2_config_file", "", "Config file to load, relative to the /cfg folder (Empty: Disables config loading)", FLAG_CVAR);
g_hWhitelistMap = CreateConVar(PLUGIN_FILE ... "_3_whitelist_map", "", "Whitelisted map name(s), case-insensitive, comma-separated (Empty: Apply to ALL maps)", FLAG_CVAR);
g_hLogConsole = CreateConVar(PLUGIN_FILE ... "_4_log_console", "1", "Toggles logging of config loading status in the console (0: Off, 1: On)", FLAG_CVAR, true, 0.0, true, 1.0);
AutoExecConfig(true, PLUGIN_FILE);
}
You can see I have to put numbering to force SM lists them by order I like, without them, SM could put the main cvar PLUGIN_FILE ... "_1_enabled" to the bottom, etc
Config file:
// This file was auto-generated by SourceMod (v1.12.0.7169)
// ConVars for plugin "map_config.smx"
// Toggles plugin state (0: Off, 1: On)
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
map_config_1_enabled "1"
// Config file to load, relative to the /cfg folder (Empty: Disables config loading)
// -
// Default: ""
map_config_2_config_file ""
// Whitelisted map name(s), case-insensitive, comma-separated (Empty: Apply to ALL maps)
// -
// Default: ""
map_config_3_whitelist_map ""
// Toggles logging of config loading status in the console (0: Off, 1: On)
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
map_config_4_log_console "1"
I'm surprised no one complain about this yet...
I'm surprised no one complain about this yet...
Anyway, at the end, you can manually rewrite whole config file the way you like it look.
If plugin configure file gets more complex+more cvars, better start look and use KeyValue file, and place under
addons\sourcemod\configs\