Generate item slot images on the fly

This commit is contained in:
Wuzzy 2020-03-24 18:48:14 +01:00
parent 3cf32c38c5
commit 7243a25fe6
31 changed files with 76 additions and 11 deletions

View file

@ -1,4 +1,5 @@
mcl_init
mcl_formspec
mesecons
mcl_sounds
mcl_tnt

View file

@ -13,7 +13,6 @@ local S = minetest.get_translator("mcl_dispensers")
local setup_dispenser = function(pos)
-- Set formspec and inventory
local form = "size[9,8.75]"..
"background[-0.19,-0.25;9.41,9.49;crafting_inventory_9_slots.png]"..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
"list[current_player;main;0,7.74;9,1;]"..

View file

@ -1,4 +1,5 @@
mcl_init
mcl_formspec
mesecons
mcl_util
doc?

View file

@ -14,7 +14,6 @@ local S = minetest.get_translator("mcl_droppers")
local setup_dropper = function(pos)
-- Set formspec and inventory
local form = "size[9,8.75]"..
"background[-0.19,-0.25;9.41,9.49;crafting_inventory_9_slots.png]"..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
"list[current_player;main;0,7.74;9,1;]"..

View file

@ -1,4 +1,5 @@
mcl_init
mcl_formspec
mcl_sounds
mcl_core?
screwdriver?

View file

@ -19,10 +19,15 @@ local function get_anvil_formspec(set_name)
"background[-0.19,-0.25;9.41,9.49;mcl_anvils_inventory.png]"..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7.74,9,1)..
"list[context;input;1,2.5;1,1;]"..
mcl_formspec.get_itemslot_bg(1,2.5,1,1)..
"list[context;input;4,2.5;1,1;1]"..
mcl_formspec.get_itemslot_bg(4,2.5,1,1)..
"list[context;output;8,2.5;1,1;]"..
mcl_formspec.get_itemslot_bg(8,2.5,1,1)..
"label[3,0.1;"..minetest.formspec_escape(minetest.colorize("#313131", S("Repair and Name"))).."]"..
"field[3.25,1;4,1;name;;"..minetest.formspec_escape(set_name).."]"..
"field_close_on_enter[name;false]"..

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 699 B

Before After
Before After

View file

@ -1,4 +1,5 @@
mcl_init
mcl_formspec
mcl_core
mcl_sounds
mcl_end

View file

@ -183,12 +183,14 @@ minetest.register_node("mcl_chests:"..basename, {
minetest.show_formspec(clicker:get_player_name(),
"mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z,
"size[9,8.75]"..
"background[-0.19,-0.25;9.41,10.48;mcl_chests_inventory_chest.png]"..
"label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Chest"))).."]"..
"list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,0.5;9,3;]"..
mcl_formspec.get_itemslot_bg(0,0.5,9,3)..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7.74,9,1)..
"listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main]"..
"listring[current_player;main]")
@ -317,13 +319,16 @@ minetest.register_node("mcl_chests:"..basename.."_left", {
minetest.show_formspec(clicker:get_player_name(),
"mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z,
"size[9,11.5]"..
"background[-0.19,-0.25;9.41,12.5;mcl_chests_inventory_chest_large.png]"..
"label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Large Chest"))).."]"..
"list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,0.5;9,3;]"..
mcl_formspec.get_itemslot_bg(0,0.5,9,3)..
"list[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main;0,3.5;9,3;]"..
mcl_formspec.get_itemslot_bg(0,3.5,9,3)..
"label[0,7;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,7.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,7.5,9,3)..
"list[current_player;main;0,10.75;9,1;]"..
mcl_formspec.get_itemslot_bg(0,10.75,9,1)..
-- BEGIN OF LISTRING WORKAROUND
"listring[current_player;main]"..
"listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";input]"..
@ -452,13 +457,16 @@ minetest.register_node("mcl_chests:"..basename.."_right", {
"mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z,
"size[9,11.5]"..
"background[-0.19,-0.25;9.41,12.5;mcl_chests_inventory_chest_large.png]"..
"label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Large Chest"))).."]"..
"list[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main;0,0.5;9,3;]"..
mcl_formspec.get_itemslot_bg(0,0.5,9,3)..
"list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,3.5;9,3;]"..
mcl_formspec.get_itemslot_bg(0,3.5,9,3)..
"label[0,7;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,7.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,7.5,9,3)..
"list[current_player;main;0,10.75;9,1;]"..
mcl_formspec.get_itemslot_bg(0,10.75,9,1)..
-- BEGIN OF LISTRING WORKAROUND
"listring[current_player;main]"..
"listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";input]"..
@ -662,12 +670,14 @@ minetest.register_node("mcl_chests:ender_chest", {
local meta = minetest.get_meta(pos)
meta:set_string("formspec",
"size[9,8.75]"..
"background[-0.19,-0.25;9.41,10.48;mcl_chests_inventory_chest.png]"..
"label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Ender Chest"))).."]"..
"list[current_player;enderchest;0,0.5;9,3;]"..
mcl_formspec.get_itemslot_bg(0,0.5,9,3)..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7.74,9,1)..
"listring[current_player;enderchest]"..
"listring[current_player;main]")
end,
@ -783,12 +793,14 @@ for color, desc in pairs(boxtypes) do
local meta = minetest.get_meta(pos)
meta:set_string("formspec",
"size[9,8.75]"..
"background[-0.19,-0.25;9.41,10.48;mcl_chests_inventory_chest.png]"..
"label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Shulker Box"))).."]"..
"list[current_name;main;0,0.5;9,3;]"..
mcl_formspec.get_itemslot_bg(0,0.5,9,3)..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7.74,9,1)..
"listring[current_name;main]"..
"listring[current_player;main]")
local inv = meta:get_inventory()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -1,2 +1,3 @@
mcl_init
mcl_formspec
mcl_sounds

View file

@ -16,13 +16,17 @@ minetest.register_node("mcl_crafting_table:crafting_table", {
player:get_inventory():set_size("craft", 9)
local form = "size[9,8.75]"..
"background[-0.19,-0.25;9.41,9.49;crafting_formspec_bg2.png^crafting_inventory_workbench.png]"..
"background[-0.19,-0.25;9.41,9.49;crafting_inventory_workbench.png]"..
"label[0,4;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7.74,9,1)..
"label[1.75,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Crafting"))).."]"..
"list[current_player;craft;1.75,0.5;3,3;]"..
mcl_formspec.get_itemslot_bg(1.75,0.5,3,3)..
"list[current_player;craftpreview;6.1,1.5;1,1;]"..
mcl_formspec.get_itemslot_bg(6.1,1.5,1,1)..
"image_button[0.75,1.5;1,1;craftguide_book.png;__mcl_craftguide;]"..
"tooltip[__mcl_craftguide;"..minetest.formspec_escape(S("Recipe book")).."]"..
"listring[current_player;main]"..

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 281 B

Before After
Before After

View file

@ -1,4 +1,5 @@
mcl_init
mcl_formspec
mcl_core
mcl_sounds
mcl_craftguide

View file

@ -7,14 +7,18 @@ local S = minetest.get_translator("mcl_furnaces")
local function active_formspec(fuel_percent, item_percent)
return "size[9,8.75]"..
"background[-0.19,-0.25;9.41,9.49;crafting_inventory_furnace.png]"..
"label[0,4;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7.74,9,1)..
"label[2.75,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Furnace"))).."]"..
"list[current_name;src;2.75,0.5;1,1;]"..
mcl_formspec.get_itemslot_bg(2.75,0.5,1,1)..
"list[current_name;fuel;2.75,2.5;1,1;]"..
mcl_formspec.get_itemslot_bg(2.75,2.5,1,1)..
"list[current_name;dst;5.75,1.5;1,1;]"..
mcl_formspec.get_itemslot_bg(5.75,2.5,1,1)..
"image[2.75,1.5;1,1;default_furnace_fire_bg.png^[lowpart:"..
(100-fuel_percent)..":default_furnace_fire_fg.png]"..
"image[4.1,1.5;1.5,1;gui_furnace_arrow_bg.png^[lowpart:"..
@ -30,14 +34,18 @@ local function active_formspec(fuel_percent, item_percent)
end
local inactive_formspec = "size[9,8.75]"..
"background[-0.19,-0.25;9.41,9.49;crafting_inventory_furnace.png]"..
"label[0,4;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7.74,9,1)..
"label[2.75,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Furnace"))).."]"..
"list[current_name;src;2.75,0.5;1,1;]"..
mcl_formspec.get_itemslot_bg(2.75,0.5,1,1)..
"list[current_name;fuel;2.75,2.5;1,1;]"..
mcl_formspec.get_itemslot_bg(2.75,2.5,1,1)..
"list[current_name;dst;5.75,1.5;1,1;]"..
mcl_formspec.get_itemslot_bg(5.75,1.5,1,1)..
"image[2.75,1.5;1,1;default_furnace_fire_bg.png]"..
"image[4.1,1.5;1.5,1;gui_furnace_arrow_bg.png^[transformR270]"..
"image_button[8,0;1,1;craftguide_book.png;craftguide;]"..

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -1,4 +1,5 @@
mcl_core
mcl_formspec
mcl_sounds
mcl_util
doc?

View file

@ -4,12 +4,14 @@ local S = minetest.get_translator("mcl_hoppers")
local mcl_hoppers_formspec =
"size[9,7]"..
"background[-0.19,-0.25;9.41,10.48;mcl_hoppers_inventory.png]"..
"label[2,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Hopper"))).."]"..
"list[current_name;main;2,0.5;5,1;]"..
mcl_formspec.get_itemslot_bg(2,0.5,5,1)..
"label[0,2;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,2.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,2.5,9,3)..
"list[current_player;main;0,5.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,5.74,9,1)..
"listring[current_name;main]"..
"listring[current_player;main]"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 992 B