From f72e57d19f6f302b90cd100934b94189cf7acf0f Mon Sep 17 00:00:00 2001 From: cheapie Date: Sat, 14 Sep 2024 16:52:46 -0500 Subject: Add luacheck configuration and some minor cleanup --- init.lua | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 814431e..c0c3c5f 100644 --- a/init.lua +++ b/init.lua @@ -20,7 +20,11 @@ function playersettings.openform(player) if type(player) == "string" then player = minetest.get_player_by_name(player) end local name = player:get_player_name() if #playersettings.settingslist < 1 then - local form = "formspec_version[4]size[12,3]label[0.5,1;No settings currently exist.]label[0.5,1.5;To use the settings menu, one or more mods that provide some settings must be installed.]button_exit[5,2;2,1;quit;Close]" + local form = "formspec_version[4]".. + "size[12,3.5]".. + "label[0.5,1;No settings currently exist.]".. + "label[0.5,1.5;To use the settings menu, one or more mods that provide some settings must be installed.]".. + "button_exit[5,2;2,1;quit;Close]" minetest.show_formspec(name,"playersettings:nosettings",form) return end @@ -65,7 +69,10 @@ function playersettings.openform(player) choices = choices:sub(1,-2) extras = extras:format(choices,selected) end - local form = playersettings.form:format(settingslist,playersettings.highlighted[name],minetest.formspec_escape(def.shortdesc),minetest.formspec_escape(def.longdesc),extras) + local highlighted = playersettings.highlighted[name] + local shortdesc = minetest.formspec_escape(def.shortdesc) + local longdesc = minetest.formspec_escape(def.longdesc) + local form = playersettings.form:format(settingslist,highlighted,shortdesc,longdesc,extras) minetest.show_formspec(name,"playersettings:settings",form) end @@ -118,7 +125,7 @@ function playersettings.get(name,setting) assert(type(setting) == "string",string.format("Invalid setting name (expected string, got %s)",type(setting))) assert(playersettings.registered[setting],"No such setting: "..setting) local value = minetest.deserialize(storage:get_string(string.format("%s|%s",name,setting))) - if value then + if value then return value else return playersettings.getdefault(setting) @@ -156,7 +163,7 @@ function playersettings.onjoin(player) end end -if minetest.get_modpath("unified_inventory") then +if minetest.global_exists("unified_inventory") then unified_inventory.register_button("playersettings", { action = playersettings.openform, -- cgit v1.2.3