From ea417616ed8d05f721bae165eef7745a572c3e50 Mon Sep 17 00:00:00 2001 From: Vitaliy Olkhin Date: Mon, 15 Jan 2024 00:31:34 +0500 Subject: [PATCH] =?UTF-8?q?=D0=B2=D1=8B=D1=80=D0=B5=D0=B7=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=B5=D1=89=D0=B5=20=D0=BD=D0=B5=D0=BC=D0=BD=D0=BE=D0=B3=D0=BE?= =?UTF-8?q?=20=D0=BD=D0=B5=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D1=83=D0=B5?= =?UTF-8?q?=D0=BC=D0=BE=D0=B3=D0=BE=20=D0=BA=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- init.lua | 61 -------------------------------------------------------- 1 file changed, 61 deletions(-) diff --git a/init.lua b/init.lua index d7a8379..cf9f422 100644 --- a/init.lua +++ b/init.lua @@ -3,30 +3,9 @@ minetest.register_privilege("builder", { give_to_singleplayer = false }) -local VERSION = "0.1.5a" local MODES = {legacy = "legacy", world = "world", session = "session"} -- this redundancy simplifies later checks local DEFAULT = {mode = MODES.world, slots = {legacy = 16, world = 10, session = 12}} local MOD_STORAGE = {} -if not core.get_mod_storage then - -- MT < 0.4.16 - MOD_STORAGE.present = false - MOD_STORAGE.settings = false -else - -- MT 0.4.16+ - MOD_STORAGE.present = true - MOD_STORAGE.settings = core.get_mod_storage() -end - - -local stringified_table_keys = function(what, sep) - -- what: table - -- sep: keys separator (a string) - local rc = "" - for k, v in pairs(what) do - rc = rc .. k .. sep - end - return string.sub(rc, 1, -#sep - 1) -end local new_masked_array = function(mask, max) local rc = {} @@ -65,11 +44,6 @@ local get_mode = function(storage, key, default_value) end if wrong then core.settings:set(key, value) - core.log("error", - "[MOD] hotbar v" .. VERSION .. - " automatically changed and saved the mode. " .. - "The mode has now been set to " .. - string.upper(value) .. ".") end return value end @@ -113,11 +87,6 @@ local get_and_set_initial_slots = function(storage, mode_value, key, default_val else current = default_value -- Unplanned case - core.log("error", - "[MOD] hotbar v" .. VERSION .. - ": the specified mode - " .. string.upper(mode_value) .. - " - is unmanaged and has been overridden and set to " .. - string.upper(default_value) .. ".") end return current @@ -148,38 +117,8 @@ hb.image.bg.get = function(slots) end hb.slots.set = function(name, slots) - local mask = {err = "[%s] Wrong slots number specified: the %s accepted value is %i.", - set = "[%s] Hotbar slots number set to %i."} - local display_name = name - if minetest.is_singleplayer() then - display_name = '_' - end - slots = math.floor(slots) -- to avoid fractions - hb.adjust(name, slots, hb.image.selected, hb.image.bg.get) - - if hb.mode.current == MODES.legacy then - core.settings:set(hb.slots.key, slots) - elseif hb.mode.current == MODES.world then - MOD_STORAGE.settings:set_string(hb.slots.key, core.serialize(slots)) - elseif hb.mode.current == MODES.session then - if core.is_singleplayer() then - -- This is an ephemeral / transient storage that is to survive while in a map - -- and trying different hotbar modes. - -- As a commodity, singleplayer can override the default value to get it back - -- if he/she switched back from another mode during the same session. - -- This has not to happen on a server to avoid that other players - -- overrided it or that their default / current value might be overridden by - -- others. - DEFAULT.slots[hb.mode.current] = slots - end - else - return - end - if hb.mode.current ~= MODES.session then - hb.slots.current = slots - end end minetest.register_on_joinplayer(function(player)