How to create config files/ convars
Posted: Thu Apr 07, 2016 9:44 pm
by decompile
Hey,
After all the updates I want to ask how to create now properly config files for a plugin.
Posted: Thu Apr 07, 2016 9:54 pm
by iPlayer
Syntax: Select all
from config.manager import ConfigManager
# Create config
with ConfigManager("my_new_plugin", cvar_prefix='mnp_') as config_manager:
config_manager.section("ConVar section 1: Useful cvars")
# Let's define mnp_cvar1
cvar1 = config_manager.cvar(
name="cvar1",
default="default_value",
description="My first console variable",
)
# Access cvar value
print(cvar1.get_string())
Also be sure to check my
ControlledCvars packageEDIT: As for descriptions and sections, you can utilize translated strings:
Syntax: Select all
from translations.strings import LangStrings
my_strings = LangStrings("my_new_plugin") # /resource/source-python/translations/my_new_plugin.ini
# ...
config_manager.section(my_strings['config section1 description'])
Posted: Thu Apr 07, 2016 11:21 pm
by decompile
Thank you!
Posted: Fri Apr 08, 2016 6:48 am
by Ayuto