diff --git a/common.lua b/common.lua index 3ceaba9..c7547a2 100644 --- a/common.lua +++ b/common.lua @@ -169,6 +169,16 @@ function fs_helpers.get_inv(y) return table.concat(fs, "") end +function fs_helpers.get_prepends(size) + local prepend = "" + + if minetest.get_modpath("i3") then + prepend = "no_prepend[]bgcolor[black;neither]background9[0,0;"..size..";i3_bg_full.png;false;10]style_type[button;border=false;bgimg=[combine:16x16^[noalpha^[colorize:#6b6b6b]" + end + + return prepend +end + --------- -- Env -- --------- diff --git a/trashcan.lua b/trashcan.lua index d9cd042..c7f25a6 100644 --- a/trashcan.lua +++ b/trashcan.lua @@ -20,14 +20,11 @@ minetest.register_node("pipeworks:trashcan", { }, on_construct = function(pos) local meta = minetest.get_meta(pos) - local prepend = "" - if minetest.get_modpath("i3") then - prepend = "no_prepend[]bgcolor[black;neither]background9[0,0;10.2,9;i3_bg_full.png;false;10]" - end + local size = "10.2,9" meta:set_string("formspec", "formspec_version[2]" .. - "size[10.2,9]".. - prepend .. + "size["..size.."]".. + pipeworks.fs_helpers.get_prepends(size) .. "item_image[0.5,0.5;1,1;pipeworks:trashcan]".. "label[1.5,1;"..S("Trash Can").."]".. "list[context;trash;4.5,2;1,1;]".. diff --git a/vacuum_tubes.lua b/vacuum_tubes.lua index 514c628..684e6cf 100644 --- a/vacuum_tubes.lua +++ b/vacuum_tubes.lua @@ -39,14 +39,11 @@ if pipeworks.enable_mese_sand_tube then groups = {vacuum_tube = 1}, on_construct = function(pos) local meta = minetest.get_meta(pos) + local size = "6.0,2.4" meta:set_int("dist", 0) - local prepend = "" - if minetest.get_modpath("i3") then - prepend = "no_prepend[]bgcolor[black;neither]background9[0,0;6.0,2.2;i3_bg_full.png;false;10]" - end meta:set_string("formspec", - "size[6.0,2.2]".. - prepend .. + "size["..size.."]".. + pipeworks.fs_helpers.get_prepends(size) .. "image[0.2,0;1,1;pipeworks_mese_sand_tube_inv.png]".. "label[1.2,0.2;"..S("Adjustable Vacuuming Tube").."]".. "field[0.5,1.6;2.1,1;dist;"..S("Radius")..";${dist}]"..