Right inventory for wifi chests

Fix #23
This commit is contained in:
Louis
2021-02-25 18:03:57 +01:00
parent 9526aec1cd
commit 109e6b1fdc
5 changed files with 59 additions and 108 deletions

View File

@ -41,13 +41,15 @@ function generate_chest_def(def)
end,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
local formspec_str = def.formspec or generate_formspec_string(def.size)
local formspec_str = def.formspec or generate_formspec_string(def.size, def.inventory_name or nil)
meta:set_string("formspec", formspec_str)
meta:set_string("infotext", def.description)
meta:set_string("owner", "")
local inv = meta:get_inventory()
local chest_size = def.size == "big" and 14*5 or 8*4
inv:set_size("main", chest_size)
if def.inventory_name == nil or def.inventory_name == "main" then
local inv = meta:get_inventory()
local chest_size = def.size == "big" and 14*5 or 8*4
inv:set_size("main", chest_size)
end
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos)

View File

@ -1,5 +1,12 @@
function generate(size)
function generate(size, inventory_name)
local cfg
-- chest inventory name
local inv_name = inventory_name
if inv_name == nil then
inv_name = "main"
end
if size == "small" then
cfg = {
window_width = 8,
@ -23,7 +30,7 @@ function generate(size)
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
"list[current_name;main;0,0.3;" ..
"list["..((inv_name == "main") and "current_name" or "current_player")..";"..inv_name..";0,0.3;" ..
cfg.chest_width .. "," .. cfg.chest_height .. ";]" ..
"list[current_player;main;" ..
player_inv_x_orig .. "," .. player_inv_y_orig ..
@ -31,7 +38,7 @@ function generate(size)
"list[current_player;main;" ..
player_inv_x_orig .. "," .. (player_inv_y_orig + 1.15) ..
";8,3;8]" ..
"listring[current_name;main]" ..
"listring["..(inv_name == "main" and "current_name" or "current_player")..";"..inv_name.."]" ..
"listring[current_player;main]" ..
default.get_hotbar_bg(player_inv_x_orig, player_inv_y_orig)
end