1
0
Fork 0

Better chest formspec

This commit is contained in:
Wuzzy 2017-01-06 00:24:50 +01:00
parent 20b804ab74
commit 3800e73eb7
4 changed files with 15 additions and 62 deletions

View File

@ -1,44 +0,0 @@
default.chest_formspec =
"size[9,9.75]"..
"background[-0.19,-0.25;9.41,10.48;crafting_inventory_chest.png]"..
default.inventory_header..
"list[current_name;main;0,0.5;9,4;]"..
"list[current_player;main;0,5.5;9,3;9]"..
"list[current_player;main;0,8.74;9,1;]"
local chest_inv_size = 4*9
local chest_inv_vers = 2
function default.get_locked_chest_formspec(pos)
local meta = minetest.get_meta(pos)
local inv_v = meta:get_int("chest_inv_ver")
if inv_v and inv_v < chest_inv_vers then
local inv = meta:get_inventory()
inv:set_size("main",chest_inv_size)
meta:set_int("chest_inv_ver",chest_inv_vers)
end
local spos = pos.x .. "," .. pos.y .. "," ..pos.z
local formspec =
"size[9,9.75]"..
"background[-0.19,-0.25;9.41,10.48;crafting_inventory_chest.png]"..
default.inventory_header..
"list[nodemeta:".. spos .. ";main;0,0.5;9,4;]"..
"list[current_player;main;0,5.5;9,3;9]"..
"list[current_player;main;0,8.74;9,1;]"
return formspec
end
minetest.register_abm({
nodenames = {"default:chest"},
interval = 1,
chance = 1,
action = function(pos, node)
local meta = minetest.get_meta(pos)
local inv_v = meta:get_int("chest_inv_ver")
if inv_v and inv_v < chest_inv_vers then
local inv = meta:get_inventory()
inv:set_size("main",chest_inv_size)
meta:set_int("chest_inv_ver",chest_inv_vers)
end
end
})

View File

@ -1,5 +1,3 @@
dofile(minetest.get_modpath("crafting").."/formspecs.lua")
local show_armor = false local show_armor = false
if minetest.get_modpath("3d_armor") ~= nil then show_armor = true end if minetest.get_modpath("3d_armor") ~= nil then show_armor = true end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

@ -1148,7 +1148,6 @@ minetest.register_node("default:chest", {
local p = get_chest_neighborpos(pos, param2, "right") local p = get_chest_neighborpos(pos, param2, "right")
meta:set_string("formspec", meta:set_string("formspec",
"size[9,11.5]".. "size[9,11.5]"..
default.inventory_header..
"list[nodemeta:"..p.x..","..p.y..","..p.z..";main;0,0;9,3;]".. "list[nodemeta:"..p.x..","..p.y..","..p.z..";main;0,0;9,3;]"..
"list[current_name;main;0,3;9,3;]".. "list[current_name;main;0,3;9,3;]"..
"list[current_player;main;0,7;9,3;9]".. "list[current_player;main;0,7;9,3;9]"..
@ -1162,7 +1161,6 @@ minetest.register_node("default:chest", {
local m = minetest.env:get_meta(p) local m = minetest.env:get_meta(p)
m:set_string("formspec", m:set_string("formspec",
"size[9,11.5]".. "size[9,11.5]"..
default.inventory_header..
"list[current_name;main;0,0;9,3;]".. "list[current_name;main;0,0;9,3;]"..
"list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,3;9,3;]".. "list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,3;9,3;]"..
"list[current_player;main;0,7;9,3;9]".. "list[current_player;main;0,7;9,3;9]"..
@ -1177,7 +1175,6 @@ minetest.register_node("default:chest", {
local p = get_chest_neighborpos(pos, param2, "left") local p = get_chest_neighborpos(pos, param2, "left")
meta:set_string("formspec", meta:set_string("formspec",
"size[9,11.5]".. "size[9,11.5]"..
default.inventory_header..
"list[current_name;main;0,0;9,3;]".. "list[current_name;main;0,0;9,3;]"..
"list[nodemeta:"..p.x..","..p.y..","..p.z..";main;0,3;9,3;]".. "list[nodemeta:"..p.x..","..p.y..","..p.z..";main;0,3;9,3;]"..
"list[current_player;main;0,7;9,3;9]".. "list[current_player;main;0,7;9,3;9]"..
@ -1191,7 +1188,6 @@ minetest.register_node("default:chest", {
local m = minetest.env:get_meta(p) local m = minetest.env:get_meta(p)
m:set_string("formspec", m:set_string("formspec",
"size[9,11.5]".. "size[9,11.5]"..
default.inventory_header..
"list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,0;9,3;]".. "list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,0;9,3;]"..
"list[current_name;main;0,3;9,3;]".. "list[current_name;main;0,3;9,3;]"..
"list[current_player;main;0,7;9,3;9]".. "list[current_player;main;0,7;9,3;9]"..
@ -1203,11 +1199,12 @@ minetest.register_node("default:chest", {
m:set_string("infotext", "Large Chest") m:set_string("infotext", "Large Chest")
else else
meta:set_string("formspec", meta:set_string("formspec",
"size[9,8.5]".. "size[9,8.75]"..
"background[-0.19,-0.25;9.41,10.48;crafting_inventory_chest.png]"..
default.inventory_header.. default.inventory_header..
"list[current_name;main;0,0;9,3;]".. "list[current_name;main;0,0.5;9,3;]"..
"list[current_player;main;0,4;9,3;9]".. "list[current_player;main;0,4.5;9,3;9]"..
"list[current_player;main;0,7.5.5;9,1;]".. "list[current_player;main;0,7.74;9,1;]"..
"listring[current_name;main]".. "listring[current_name;main]"..
"listring[current_player;main]") "listring[current_player;main]")
meta:set_string("infotext", "Chest") meta:set_string("infotext", "Chest")
@ -1263,11 +1260,12 @@ minetest.register_node("default:chest_left", {
end end
local meta = minetest.env:get_meta(p) local meta = minetest.env:get_meta(p)
meta:set_string("formspec", meta:set_string("formspec",
"size[9,8.5]".. "size[9,8.75]"..
"background[-0.19,-0.25;9.41,10.48;crafting_inventory_chest.png]"..
default.inventory_header.. default.inventory_header..
"list[current_name;main;0,0;9,3;]".. "list[current_name;main;0,0.5;9,3;]"..
"list[current_player;main;0,4;9,3;9]".. "list[current_player;main;0,4.5;9,3;9]"..
"list[current_player;main;0,7.5.5;9,1;]".. "list[current_player;main;0,7.74;9,1;]"..
"listring[current_name;main]".. "listring[current_name;main]"..
"listring[current_player;main]") "listring[current_player;main]")
meta:set_string("infotext", "Chest") meta:set_string("infotext", "Chest")
@ -1321,11 +1319,12 @@ minetest.register_node("default:chest_right", {
end end
local meta = minetest.env:get_meta(p) local meta = minetest.env:get_meta(p)
meta:set_string("formspec", meta:set_string("formspec",
"size[9,8.5]".. "size[9,8.75]"..
"background[-0.19,-0.25;9.41,10.48;crafting_inventory_chest.png]"..
default.inventory_header.. default.inventory_header..
"list[current_name;main;0,0;9,3;]".. "list[current_name;main;0,0.5;9,3;]"..
"list[current_player;main;0,4;9,3;9]".. "list[current_player;main;0,4.5;9,3;9]"..
"list[current_player;main;0,7.5.5;9,1;]".. "list[current_player;main;0,7.74;9,1;]"..
"listring[current_name;main]".. "listring[current_name;main]"..
"listring[current_player;main]") "listring[current_player;main]")
meta:set_string("infotext", "Chest") meta:set_string("infotext", "Chest")