Blackheart OT
Defense in depth
Hello fellow developer,
I am trying to learn how the variables in config.lua are read and used by the cpp code. Let me start with what I think I understand so far, for this lets use the example of the variable rateSkill.
I believe this is loaded from the config.lua by "m_confInteger[RATE_SKILL] = getGlobalNumber(L, "rateSkill", 3)" in configmanager.cpp and placed in table m_confInteger at position RATE_SKILL, which is defined in configmanager.h as part of the enumeration integer_config_t. Lastly, when this value is wanted, the function ConfigManager::getNumber(integer_config_t _what) is called to retrieve it from the
m_confInteger table.
If my statements above are correct, that to add a new value to config.lua and have it available in cpp, one needs to 1) add a line similar to "m_confInteger[RATE_SKILL] = getGlobalNumber(L, "varName", default)" to configmanager.cpp, 2) add a new row "VAR_NAME = nextNumber" to enum integer_config_t, and 3) to use the value, i have to add the line "extern ConfigManager g_config," to my file, and then "g_config.getNumber(ConfigManager::VAR_NAME)" when i want the value. Please let me know if this is correct and optimal.
Thanks,
Mike
I am trying to learn how the variables in config.lua are read and used by the cpp code. Let me start with what I think I understand so far, for this lets use the example of the variable rateSkill.
I believe this is loaded from the config.lua by "m_confInteger[RATE_SKILL] = getGlobalNumber(L, "rateSkill", 3)" in configmanager.cpp and placed in table m_confInteger at position RATE_SKILL, which is defined in configmanager.h as part of the enumeration integer_config_t. Lastly, when this value is wanted, the function ConfigManager::getNumber(integer_config_t _what) is called to retrieve it from the
m_confInteger table.
If my statements above are correct, that to add a new value to config.lua and have it available in cpp, one needs to 1) add a line similar to "m_confInteger[RATE_SKILL] = getGlobalNumber(L, "varName", default)" to configmanager.cpp, 2) add a new row "VAR_NAME = nextNumber" to enum integer_config_t, and 3) to use the value, i have to add the line "extern ConfigManager g_config," to my file, and then "g_config.getNumber(ConfigManager::VAR_NAME)" when i want the value. Please let me know if this is correct and optimal.
Thanks,
Mike