summaryrefslogtreecommitdiff
path: root/hotbar
diff options
context:
space:
mode:
Diffstat (limited to 'hotbar')
-rw-r--r--hotbar/init.lua33
-rw-r--r--hotbar/textures/gui_hb_bg.pngbin474 -> 0 bytes
-rw-r--r--hotbar/textures/gui_hb_bg_1.pngbin0 -> 246 bytes
-rw-r--r--hotbar/textures/gui_hb_bg_16.pngbin764 -> 763 bytes
-rw-r--r--hotbar/textures/gui_hb_bg_23.pngbin971 -> 952 bytes
-rw-r--r--hotbar/textures/gui_hb_bg_24.pngbin0 -> 984 bytes
-rw-r--r--hotbar/textures/gui_hb_bg_32.pngbin0 -> 1203 bytes
-rw-r--r--hotbar/textures/gui_hb_bg_8.pngbin0 -> 479 bytes
8 files changed, 19 insertions, 14 deletions
diff --git a/hotbar/init.lua b/hotbar/init.lua
index 71b48f4..81b0518 100644
--- a/hotbar/init.lua
+++ b/hotbar/init.lua
@@ -1,4 +1,15 @@
-local hotbar_size_default = minetest.setting_get("hotbar_size") or 16
+local mtver = minetest.get_version()
+local maxslots = (string.sub(mtver.string, 1, 4) ~= "0.4.") and 32 or 23
+
+local function validate_size(s)
+ local size = s and tonumber(s) or 16
+ if (size == 8 or size == 16 or size == 23 or size == 24 or size == 32)
+ and size <= maxslots then
+ return size
+ end
+end
+
+local hotbar_size_default = validate_size(minetest.setting_get("hotbar_size"))
local player_hotbar_settings = {}
@@ -27,18 +38,12 @@ end
load_hotbar_settings()
-local function resize_hotbar(size)
- if size == 8 then return "gui_hb_bg.png" end
- if size == 23 then return "gui_hb_bg_23.png" end
- return "gui_hb_bg_16.png"
-end
-
minetest.register_on_joinplayer(function(player)
- local hotbar_size = get_hotbar_setting(player:get_player_name())
+ local hotbar_size = validate_size(get_hotbar_setting(player:get_player_name()))
player:hud_set_hotbar_itemcount(hotbar_size)
minetest.after(0.5,function(hotbar_size)
player:hud_set_hotbar_selected_image("gui_hotbar_selected.png")
- player:hud_set_hotbar_image(resize_hotbar(hotbar_size))
+ player:hud_set_hotbar_image("gui_hb_bg_"..hotbar_size..".png")
end,hotbar_size)
end)
@@ -46,12 +51,12 @@ minetest.register_chatcommand("hotbar", {
params = "[size]",
description = "Sets the size of your hotbar",
func = function(name, slots)
- if slots ~= "8" and slots ~= "23" then slots = "16" end
- player_hotbar_settings[name] = slots
+ hotbar_size = validate_size(tonumber(slots))
+ player_hotbar_settings[name] = hotbar_size
local player = minetest.get_player_by_name(name)
- player:hud_set_hotbar_itemcount(tonumber(slots))
- minetest.chat_send_player(name, "[_] Hotbar size set to " .. tonumber(slots) .. ".")
- player:hud_set_hotbar_image(resize_hotbar(tonumber(slots)))
+ player:hud_set_hotbar_itemcount(hotbar_size)
+ minetest.chat_send_player(name, "[_] Hotbar size set to " ..hotbar_size.. ".")
+ player:hud_set_hotbar_image("gui_hb_bg_"..hotbar_size..".png")
save_hotbar_settings()
end,
})
diff --git a/hotbar/textures/gui_hb_bg.png b/hotbar/textures/gui_hb_bg.png
deleted file mode 100644
index 9389700..0000000
--- a/hotbar/textures/gui_hb_bg.png
+++ /dev/null
Binary files differ
diff --git a/hotbar/textures/gui_hb_bg_1.png b/hotbar/textures/gui_hb_bg_1.png
new file mode 100644
index 0000000..d2d02c0
--- /dev/null
+++ b/hotbar/textures/gui_hb_bg_1.png
Binary files differ
diff --git a/hotbar/textures/gui_hb_bg_16.png b/hotbar/textures/gui_hb_bg_16.png
index 2624cd0..b8a52a9 100644
--- a/hotbar/textures/gui_hb_bg_16.png
+++ b/hotbar/textures/gui_hb_bg_16.png
Binary files differ
diff --git a/hotbar/textures/gui_hb_bg_23.png b/hotbar/textures/gui_hb_bg_23.png
index 53f0294..51ba70f 100644
--- a/hotbar/textures/gui_hb_bg_23.png
+++ b/hotbar/textures/gui_hb_bg_23.png
Binary files differ
diff --git a/hotbar/textures/gui_hb_bg_24.png b/hotbar/textures/gui_hb_bg_24.png
new file mode 100644
index 0000000..fb101a2
--- /dev/null
+++ b/hotbar/textures/gui_hb_bg_24.png
Binary files differ
diff --git a/hotbar/textures/gui_hb_bg_32.png b/hotbar/textures/gui_hb_bg_32.png
new file mode 100644
index 0000000..57dd588
--- /dev/null
+++ b/hotbar/textures/gui_hb_bg_32.png
Binary files differ
diff --git a/hotbar/textures/gui_hb_bg_8.png b/hotbar/textures/gui_hb_bg_8.png
new file mode 100644
index 0000000..45e1ef2
--- /dev/null
+++ b/hotbar/textures/gui_hb_bg_8.png
Binary files differ