2020-05-24 15:46:26 +02:00
|
|
|
minetest.register_node("chest:chest", {
|
2020-09-04 20:50:03 +02:00
|
|
|
description = "Chest" .. "\n" ..
|
|
|
|
"32 inventory slots",
|
2020-05-24 15:46:26 +02:00
|
|
|
tiles ={"chest_chest.png^[sheet:2x2:0,0", "chest_chest.png^[sheet:2x2:0,0",
|
|
|
|
"chest_chest.png^[sheet:2x2:1,0", "chest_chest.png^[sheet:2x2:1,0",
|
|
|
|
"chest_chest.png^[sheet:2x2:1,0", "chest_chest.png^[sheet:2x2:0,1"},
|
|
|
|
paramtype2 = "facedir",
|
|
|
|
groups = {dig_immediate=2,choppy=3},
|
|
|
|
is_ground_content = false,
|
|
|
|
on_construct = function(pos)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
meta:set_string("formspec",
|
|
|
|
"size[8,9]"..
|
|
|
|
"list[current_name;main;0,0;8,4;]"..
|
|
|
|
"list[current_player;main;0,5;8,4;]" ..
|
|
|
|
"listring[]")
|
|
|
|
meta:set_string("infotext", "Chest")
|
|
|
|
local inv = meta:get_inventory()
|
|
|
|
inv:set_size("main", 8*4)
|
|
|
|
end,
|
|
|
|
can_dig = function(pos,player)
|
|
|
|
local meta = minetest.get_meta(pos);
|
|
|
|
local inv = meta:get_inventory()
|
|
|
|
return inv:is_empty("main")
|
|
|
|
end,
|
2021-02-21 20:02:23 +01:00
|
|
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
|
|
|
minetest.chat_send_player(player:get_player_name(), "Allow put: " .. stack:to_string())
|
|
|
|
return stack:get_count()
|
|
|
|
end,
|
|
|
|
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
|
|
|
minetest.chat_send_player(player:get_player_name(), "Allow take: " .. stack:to_string())
|
|
|
|
return stack:get_count()
|
|
|
|
end,
|
|
|
|
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
|
|
|
minetest.chat_send_player(player:get_player_name(), "On put: " .. stack:to_string())
|
|
|
|
end,
|
|
|
|
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
|
|
|
minetest.chat_send_player(player:get_player_name(), "On take: " .. stack:to_string())
|
|
|
|
end,
|
2020-05-24 15:46:26 +02:00
|
|
|
})
|