diff options
author | cheapie <no-email-for-you@example.com> | 2024-09-14 16:52:46 -0500 |
---|---|---|
committer | cheapie <no-email-for-you@example.com> | 2024-09-14 16:52:46 -0500 |
commit | f72e57d19f6f302b90cd100934b94189cf7acf0f (patch) | |
tree | 6f2708cb0284b5a2925da521dad12aa36f870df2 | |
parent | 17dc9a8247c35b9710741d0f23d502e7d66d37ba (diff) | |
download | playersettings-f72e57d19f6f302b90cd100934b94189cf7acf0f.tar playersettings-f72e57d19f6f302b90cd100934b94189cf7acf0f.tar.gz playersettings-f72e57d19f6f302b90cd100934b94189cf7acf0f.tar.bz2 playersettings-f72e57d19f6f302b90cd100934b94189cf7acf0f.tar.xz playersettings-f72e57d19f6f302b90cd100934b94189cf7acf0f.zip |
-rw-r--r-- | .luacheckrc | 10 | ||||
-rw-r--r-- | init.lua | 15 |
2 files changed, 21 insertions, 4 deletions
diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..1b67400 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,10 @@ +max_line_length = 160 + +globals = { + "playersettings", +} + +read_globals = { + "minetest", + "unified_inventory", +} @@ -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, |