Some fixes
This commit is contained in:
parent
aa8e030ed2
commit
f9d8f4c053
@ -171,7 +171,7 @@ namespace mod_stats
|
||||
return get_stats().access<nlohmann::json>([&](mod_stats_t& stats)
|
||||
-> nlohmann::json
|
||||
{
|
||||
if (!stats.is_object() || !stats[name].is_object() || stats[name].is_null())
|
||||
if (!stats.is_object() || !stats[name].is_object() || stats[name][field].is_null())
|
||||
{
|
||||
return default_value;
|
||||
}
|
||||
|
@ -534,6 +534,13 @@ namespace ui_scripting
|
||||
return json_to_lua(mod_stats::get_struct(mapname, key));
|
||||
};
|
||||
|
||||
mods_stats_table["getstructor"] = [](const std::string& mapname,
|
||||
const std::string& key, const script_value& default_value)
|
||||
{
|
||||
const auto json_default_value = lua_to_json(default_value);
|
||||
return json_to_lua(mod_stats::get_struct(mapname, key, json_default_value));
|
||||
};
|
||||
|
||||
mods_stats_table["save"] = mod_stats::write;
|
||||
mods_stats_table["getall"] = []()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user