From f7874dbfd9b47c14f85f11d8bfc1a09ad12870f4 Mon Sep 17 00:00:00 2001 From: Vanessa Dannenberg Date: Sun, 23 Sep 2018 19:55:27 -0400 Subject: split the hotbar code into its own mod, added a 23-slot mode --- dreambuilder_mp_extras/init.lua | 31 ++----------------------------- hotbar/depends.txt | 1 + hotbar/init.lua | 29 +++++++++++++++++++++++++++++ hotbar/textures/gui_hb_bg.png | Bin 0 -> 474 bytes hotbar/textures/gui_hb_bg_16.png | Bin 0 -> 764 bytes hotbar/textures/gui_hb_bg_23.png | Bin 0 -> 971 bytes 6 files changed, 32 insertions(+), 29 deletions(-) create mode 100644 hotbar/depends.txt create mode 100644 hotbar/init.lua create mode 100644 hotbar/textures/gui_hb_bg.png create mode 100644 hotbar/textures/gui_hb_bg_16.png create mode 100644 hotbar/textures/gui_hb_bg_23.png diff --git a/dreambuilder_mp_extras/init.lua b/dreambuilder_mp_extras/init.lua index 65c352f..e2ee62f 100644 --- a/dreambuilder_mp_extras/init.lua +++ b/dreambuilder_mp_extras/init.lua @@ -1,34 +1,7 @@ -- This mod contains a number of features specific to dreambuilder --- such as mesh-based apples, 16-slot hotbar, some color settings, etc. +-- such as mesh-based apples, some color settings, etc. -- --- by Vanessa Ezekowitz - -local hotbar_size = minetest.setting_get("hotbar_size") or 16 - -local function resize_hotbar(size) - if size > 8 then return "gui_hb_bg_16.png" end - return "gui_hb_bg.png" -end - -minetest.register_on_joinplayer(function(player) - player:hud_set_hotbar_itemcount(hotbar_size) - minetest.after(0.5,function() - player:hud_set_hotbar_selected_image("gui_hotbar_selected.png") - player:hud_set_hotbar_image(resize_hotbar(hotbar_size)) - end) -end) - -minetest.register_chatcommand("hotbar", { - params = "[size]", - description = "Sets the size of your hotbar", - func = function(name, slots) - if slots ~= "8" then slots = "16" end - 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))) - end, -}) +-- by Vanessa Dannenberg default.gui_bg = "bgcolor[#08080899;false]" diff --git a/hotbar/depends.txt b/hotbar/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/hotbar/depends.txt @@ -0,0 +1 @@ +default diff --git a/hotbar/init.lua b/hotbar/init.lua new file mode 100644 index 0000000..f57ccc4 --- /dev/null +++ b/hotbar/init.lua @@ -0,0 +1,29 @@ + +local hotbar_size = minetest.setting_get("hotbar_size") or 16 + +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) + player:hud_set_hotbar_itemcount(hotbar_size) + minetest.after(0.5,function() + player:hud_set_hotbar_selected_image("gui_hotbar_selected.png") + player:hud_set_hotbar_image(resize_hotbar(hotbar_size)) + end) +end) + +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 + 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))) + end, +}) + diff --git a/hotbar/textures/gui_hb_bg.png b/hotbar/textures/gui_hb_bg.png new file mode 100644 index 0000000..9389700 Binary files /dev/null and b/hotbar/textures/gui_hb_bg.png differ diff --git a/hotbar/textures/gui_hb_bg_16.png b/hotbar/textures/gui_hb_bg_16.png new file mode 100644 index 0000000..2624cd0 Binary files /dev/null and b/hotbar/textures/gui_hb_bg_16.png differ diff --git a/hotbar/textures/gui_hb_bg_23.png b/hotbar/textures/gui_hb_bg_23.png new file mode 100644 index 0000000..53f0294 Binary files /dev/null and b/hotbar/textures/gui_hb_bg_23.png differ -- cgit v1.2.3