A float in minetest.conf or in the modstorage is now automatically converted into an int.

This commit is contained in:
Aristotle 2018-08-27 19:32:15 +02:00
parent f2c15725a1
commit 079d464d30

View File

@ -23,6 +23,7 @@
-- - Went back to just one command: hotbar, now improved to just not take
-- the size, but the mode as well.
-- - Some feedback messages have been fixed.
-- - luacheck has been activated and a couple of fixes have followed.
-- 0.1.4
-- - A new command - /hotbar_mode - has been added to take advantage of
-- the 0.4.16+ mod_storage API.
@ -153,15 +154,24 @@ local get_and_set_initial_slots = function(storage, mode_value, key, default_val
local result = tonumber(core.settings:get(key))
current = result or default_value -- The first time
if not result then
-- first time
core.settings:set(key, current)
else
current = math.floor(result) -- fix result to current
current = math.floor(result)
if current ~= result then
-- result is a float
core.settings:set(key, current)
end
end
elseif mode_value == MODES.world then
local result = core.deserialize(storage.settings:get_string(key))
if type(result) == "number" then
current = result
current = math.floor(result)
if current ~= result then
-- result is a float
storage.settings:set_string(key, core.serialize(current))
end
else
current = default_value -- The first time
storage.settings:set_string(key, core.serialize(current))