From e0eab5029085880c5398db0974fc56a296fd69ff Mon Sep 17 00:00:00 2001 From: FaceDeer Date: Fri, 26 Aug 2022 23:49:19 -0600 Subject: [PATCH] add backgrounds to item slots in MCL --- df_dependencies/helper_functions.lua | 15 ++++++++++++--- df_underworld_items/puzzle_chest.lua | 4 ++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/df_dependencies/helper_functions.lua b/df_dependencies/helper_functions.lua index 5d86b51..427f18b 100644 --- a/df_dependencies/helper_functions.lua +++ b/df_dependencies/helper_functions.lua @@ -195,9 +195,18 @@ elseif minetest.get_modpath("mcl_explosions") then end df_dependencies.mods_required.mcl_formspec = true -df_dependencies.get_itemslot_bg = function(X,Y,W,H) - return "" -end +df_dependencies.get_itemslot_bg = function(X,Y,W,H) return "" end +df_dependencies.get_itemslot_bg_padded = function(X,Y,W,H) return "" end if minetest.get_modpath("mcl_formspec") then df_dependencies.get_itemslot_bg = mcl_formspec.get_itemslot_bg + + df_dependencies.get_itemslot_bg_padded = function(x,y,w,h, padding) + local out = "" + for i = 0, w - 1, 1 do + for j = 0, h - 1, 1 do + out = out .."image["..x+i+(i*padding)..","..y+j+(j*padding)..";1,1;mcl_formspec_itemslot.png]" + end + end + return out + end end \ No newline at end of file diff --git a/df_underworld_items/puzzle_chest.lua b/df_underworld_items/puzzle_chest.lua index 92e94a7..2579f98 100644 --- a/df_underworld_items/puzzle_chest.lua +++ b/df_underworld_items/puzzle_chest.lua @@ -47,6 +47,8 @@ end local prefix = "df_underworld_items:puzzle_chest" local prefix_len = string.len("df_underworld_items:puzzle_chest") +local itemslot_bg = df_dependencies.get_itemslot_bg_padded + local show_formspec = function(pos, node, clicker, itemstack, pointed_thing) local meta = minetest.get_meta(pos) initialize(pos, meta) @@ -69,10 +71,12 @@ local show_formspec = function(pos, node, clicker, itemstack, pointed_thing) .. "container[1,2.75]" .. formspec_bar(false, state_sum[3], key_sum[3]) .. "container_end[]" .. "container[4,2.75]" .. formspec_bar(false, state_sum[4], key_sum[4]) .. "container_end[]" .. "container_end[]" + .. itemslot_bg(0.6,6.7,8,4,0.25) .. "list[current_player;main;0.6,6.7;8,4;]" if solved then local nodemeta = "nodemeta:"..pos.x..","..pos.y..","..pos.z formspec = formspec + .. itemslot_bg(0.6,5.4,8,1,0.25) .. "list["..nodemeta..";main;0.6,5.4;8,1;]" .. "listring[]" if meta:get_string("solved") ~= "true" then