From 7f93e8aa0a5d58ee1cd1509b0d11205aab462262 Mon Sep 17 00:00:00 2001 From: "Github is a non-free platform owned by Microsoft. Reasonable alternatives exist, such as Gitea, Sourcehut. We need a federated, mastodon-like forge based on ForgeFed. See: https://forgefed.org" Date: Fri, 25 Aug 2023 02:50:49 +0200 Subject: [PATCH] MineClone formspec compat (#82) * MineClone list backgrounds compat * mineclone get inv func --- autocrafter.lua | 2 +- common.lua | 25 +++++++++++++++++++++++++ filter-injector.lua | 2 +- sorting_tubes.lua | 2 +- trashcan.lua | 2 +- wielder.lua | 2 +- 6 files changed, 30 insertions(+), 5 deletions(-) diff --git a/autocrafter.lua b/autocrafter.lua index 00869e1..8d9936e 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -190,7 +190,7 @@ local function update_meta(meta, enabled) local state = enabled and "on" or "off" meta:set_int("enabled", enabled and 1 or 0) local list_backgrounds = "" - if minetest.get_modpath("i3") then + if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then list_backgrounds = "style_type[box;colors=#666]" for i=0, 2 do for j=0, 2 do diff --git a/common.lua b/common.lua index 1161ba6..3a45e91 100644 --- a/common.lua +++ b/common.lua @@ -168,6 +168,31 @@ function fs_helpers.get_inv(y) end end + table.insert(fs, "style_type[list;size="..size..";spacing="..spacing.."]") + table.insert(fs, "list[current_player;main;"..inv_x..","..(inv_y + 1.15)..";"..hotbar_len..","..(inv_size / hotbar_len)..";"..hotbar_len.."]") + elseif minetest.get_modpath("mcl_formspec") then + local inv_x = 0.22 + local inv_y = (y + 0.4) or 6.9 + local size, spacing = 1, 0.1 + local hotbar_len = 9 + local inv_size = hotbar_len * 4 + + table.insert(fs, "style_type[box;colors=#77777710,#77777710,#777,#777]") + + for i = 0, hotbar_len - 1 do + table.insert(fs, "box["..(i * size + inv_x + (i * spacing))..","..inv_y..";"..size..","..size..";]") + end + + table.insert(fs, "style_type[list;size="..size..";spacing="..spacing.."]") + table.insert(fs, "list[current_player;main;"..inv_x..","..inv_y..";"..hotbar_len..",1;]") + + table.insert(fs, "style_type[box;colors=#666]") + for i=0, 2 do + for j=0, hotbar_len - 1 do + table.insert(fs, "box["..0.2+(j*0.1)+(j*size)..","..(inv_y+size+spacing+0.05)+(i*0.1)+(i*size)..";"..size..","..size..";]") + end + end + table.insert(fs, "style_type[list;size="..size..";spacing="..spacing.."]") table.insert(fs, "list[current_player;main;"..inv_x..","..(inv_y + 1.15)..";"..hotbar_len..","..(inv_size / hotbar_len)..";"..hotbar_len.."]") else diff --git a/filter-injector.lua b/filter-injector.lua index ac98a62..414e249 100644 --- a/filter-injector.lua +++ b/filter-injector.lua @@ -38,7 +38,7 @@ local function set_filter_formspec(data, meta) end local size = "10.2,11" local list_backgrounds = "" - if minetest.get_modpath("i3") then + if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then list_backgrounds = "style_type[box;colors=#666]" for i=0, 7 do for j=0, 1 do diff --git a/sorting_tubes.lua b/sorting_tubes.lua index d35308f..39a8686 100644 --- a/sorting_tubes.lua +++ b/sorting_tubes.lua @@ -24,7 +24,7 @@ if pipeworks.enable_mese_tube then ) end local list_backgrounds = "" - if minetest.get_modpath("i3") then + if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then list_backgrounds = "style_type[box;colors=#666]" for i=0, 5 do for j=0, 5 do diff --git a/trashcan.lua b/trashcan.lua index 7c3d4e9..2795540 100644 --- a/trashcan.lua +++ b/trashcan.lua @@ -23,7 +23,7 @@ minetest.register_node("pipeworks:trashcan", { local meta = minetest.get_meta(pos) local size = "10.2,9" local list_background = "" - if minetest.get_modpath("i3") then + if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then list_background = "style_type[box;colors=#666]box[4.5,2;1,1;]" end meta:set_string("formspec", diff --git a/wielder.lua b/wielder.lua index 360a7bd..c5b5ec9 100644 --- a/wielder.lua +++ b/wielder.lua @@ -8,7 +8,7 @@ end local function set_wielder_formspec(data, meta) local size = "10.2,"..(7+data.wield_inv_height) local list_background = "" - if minetest.get_modpath("i3") then + if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then list_background = "style_type[box;colors=#666]" for i=0, data.wield_inv_height-1 do for j=0, data.wield_inv_width-1 do