• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

From config.lua To Cpp

Blackheart OT

Defense in depth
Joined
Nov 21, 2014
Messages
26
Reaction score
2
Location
USA
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 suppose that depends on what you want to add, the m_confInteger would probably not allow strings but only integers. But generally what you discuss seems valid, the last parameter in the getGlobalNumber is presumably the default value, no especial optimization is needed here.

You should try it out, see if it works.

Ignazio
 
Back
Top