Fix: minetest.settings:get() doesn't return actual value when unset.

master
aa6 2022-02-22 22:07:49 +03:00
parent 3307c3408a
commit 562e080d64
6 changed files with 19 additions and 13 deletions

View File

@ -1 +1 @@
0.11.6
0.11.7

View File

@ -3,6 +3,7 @@
-- Common config values.
minetest_wadsprint.HIDE_HUD_BARS = false
minetest_wadsprint.STAMINA_MAX_VALUE = 100
minetest_wadsprint.ENABLE_INGAME_SETTINGS = true
minetest_wadsprint.DYSPNEA_THRESHOLD_VALUE = 3
minetest_wadsprint.SAVE_PLAYERS_STATS_TO_FILE = true
minetest_wadsprint.PLAYERS_STATS_FILE_LIMIT_RECORDS = 1000

View File

@ -4,19 +4,20 @@ dofile(minetest.get_modpath(minetest.get_current_modname()).."/config.lua")
-- Processing in-game settings. In-game settings are preferrable
-- over global config.lua values.
function minetest_wadsprint.load_minetest_settings_key(key,type)
if type == "int" then
if minetest.settings:get("minetest_wadsprint."..key) ~= nil then
minetest_wadsprint[key] = tonumber(minetest.settings:get("minetest_wadsprint."..key))
if type == "int" then
if minetest.settings:get("minetest_wadsprint."..key) ~= nil then
minetest_wadsprint[key] = tonumber(minetest.settings:get("minetest_wadsprint."..key))
end
elseif type == "bool" then
if minetest.settings:get_bool("minetest_wadsprint."..key) ~= nil then
minetest_wadsprint[key] = minetest.settings:get_bool("minetest_wadsprint."..key)
end
end
elseif type == "bool" then
if minetest.settings:get_bool("minetest_wadsprint."..key) ~= nil then
minetest_wadsprint[key] = minetest.settings:get_bool("minetest_wadsprint."..key)
end
end
minetest_wadsprint.log(minetest.settings:get("minetest_wadsprint."..key))
end
minetest_wadsprint.load_minetest_settings_key("ENABLE_INGAME_SETTINGS","bool")
if minetest_wadsprint.ENABLE_INGAME_SETTINGS == true then
print("In-game minetest settings are enabled. Loading them.")
minetest_wadsprint.log("In-game minetest settings are enabled. Loading them.")
minetest_wadsprint.load_minetest_settings_key("HIDE_HUD_BARS","bool")
minetest_wadsprint.load_minetest_settings_key("STAMINA_MAX_VALUE","int")
minetest_wadsprint.load_minetest_settings_key("DYSPNEA_THRESHOLD_VALUE","int")
@ -29,16 +30,16 @@ if minetest_wadsprint.ENABLE_INGAME_SETTINGS == true then
minetest_wadsprint.load_minetest_settings_key("SPRINT_STAMINA_DECREASE_PER_SECOND_PERCENTS","int")
minetest_wadsprint.load_minetest_settings_key("SPRINT_STAMINA_INCREASE_PER_SECOND_PERCENTS","int")
else
print("In-game minetest settings are disabled. Ignoring them.")
minetest_wadsprint.log("In-game minetest settings are disabled. Ignoring them.")
end
-- Processing world-specific config. World-specific values are preferrable
-- over both global config and in-game settings.
if file_exists(minetest_wadsprint.worldconfig) then
print("Loading minetest_wadsprint world-specific config: "..minetest_wadsprint.worldconfig)
minetest_wadsprint.log("Loading minetest_wadsprint world-specific config: "..minetest_wadsprint.worldconfig)
dofile(minetest_wadsprint.worldconfig)
else
print("Creating minetest_wadsprint world-specific config: "..minetest_wadsprint.worldconfig)
minetest_wadsprint.log("Creating minetest_wadsprint world-specific config: "..minetest_wadsprint.worldconfig)
local new_world_config_contents =
"-- World-specific config. Values are taken from `mods/minetest_wadsprint/config.lua`:\n"..
"-- Please uncomment lines of your need and set the desired value.\n"

3
init.log.lua Normal file
View File

@ -0,0 +1,3 @@
function minetest_wadsprint.log(message)
print("minetest_wadsprint: "..dump(message))
end

View File

@ -29,6 +29,7 @@ minetest_wadsprint =
worldconfig = minetest.get_worldpath().."/mod_minetest_wadsprint_config.lua",
}
dofile(minetest.get_modpath(minetest.get_current_modname()).."/init.api.lua")
dofile(minetest.get_modpath(minetest.get_current_modname()).."/init.log.lua")
dofile(minetest.get_modpath(minetest.get_current_modname()).."/init.core.lua")
dofile(minetest.get_modpath(minetest.get_current_modname()).."/init.legacy.lua")
dofile(minetest.get_modpath(minetest.get_current_modname()).."/init.config.lua")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB