Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local override_ini_getters = { "r_bool", "r_float", "r_clsid", "r_s32", "r_token", "r_vector", "r_u32", "r_string_wq", "r_string" }
- function add_safe_getters(target)
- target.line_exist_safe = function(ini, section, line)
- return ini:section_exist(section) and ini:line_exist(section, line)
- end
- for fi, k in ipairs(override_ini_getters) do
- target[k.."_safe"] = function(ini, section, line, ...)
- if ini:line_exist_safe(section, line) then
- return ini[k](ini, section, line, ...)
- end
- return nil
- end
- end
- end
- local ini_table = {
- ["system.ltx"] = system_ini(),
- ["game.ltx"] = game_ini()
- }
- add_safe_getters(ini_file)
- add_safe_getters(ini_table["system.ltx"])
- add_safe_getters(ini_table["game.ltx"])
- __ini_file = ini_file
- ini_file = function(file_name)
- local result_file = ini_table[file_name]
- if not result_file then
- result_file = __ini_file(file_name)
- ini_table[file_name] = result_file
- end
- return result_file
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement