2024-06-21 11:15:39 +02:00
|
|
|
local S = minetest.get_translator(minetest.get_current_modname())
|
|
|
|
local F = minetest.formspec_escape
|
|
|
|
local C = minetest.colorize
|
|
|
|
local get_double_container_neighbor_pos = mcl_util.get_double_container_neighbor_pos
|
|
|
|
local trapped_chest_mesecons_rules = mesecon.rules.pplate
|
|
|
|
|
|
|
|
local chestusage = S("To access its inventory, rightclick it. When broken, the items will drop out.")
|
|
|
|
|
2024-06-21 15:22:26 +02:00
|
|
|
mcl_chests.register_chest("chest", {
|
|
|
|
desc = S("Chest"),
|
|
|
|
longdesc = S(
|
2024-06-21 13:43:12 +02:00
|
|
|
"Chests are containers which provide 27 inventory slots. Chests can be turned into large chests with " ..
|
|
|
|
"double the capacity by placing two chests next to each other."
|
|
|
|
),
|
2024-06-21 15:22:26 +02:00
|
|
|
usagehelp = chestusage,
|
|
|
|
tt_help = S("27 inventory slots") .. "\n" .. S("Can be combined to a large chest"),
|
|
|
|
tiles = {
|
2024-06-21 11:15:39 +02:00
|
|
|
small = mcl_chests.tiles.chest_normal_small,
|
|
|
|
double = mcl_chests.tiles.chest_normal_double,
|
|
|
|
inv = { "default_chest_top.png", "mcl_chests_chest_bottom.png",
|
|
|
|
"mcl_chests_chest_right.png", "mcl_chests_chest_left.png",
|
|
|
|
"mcl_chests_chest_back.png", "default_chest_front.png" },
|
|
|
|
},
|
2024-06-22 12:05:08 +02:00
|
|
|
groups = {
|
|
|
|
handy = 1,
|
|
|
|
axey = 1,
|
|
|
|
material_wood = 1,
|
|
|
|
flammable = -1,
|
|
|
|
},
|
2024-06-21 15:22:26 +02:00
|
|
|
sounds = mcl_sounds.node_sound_wood_defaults(),
|
|
|
|
hardness = 2.5,
|
|
|
|
hidden = false,
|
|
|
|
})
|
2024-06-21 11:15:39 +02:00
|
|
|
|
|
|
|
local traptiles = {
|
|
|
|
small = mcl_chests.tiles.chest_trapped_small,
|
|
|
|
double = mcl_chests.tiles.chest_trapped_double,
|
|
|
|
}
|
|
|
|
|
2024-06-21 15:22:26 +02:00
|
|
|
mcl_chests.register_chest("trapped_chest", {
|
|
|
|
desc = S("Trapped Chest"),
|
|
|
|
longdesc = S(
|
2024-06-21 13:43:12 +02:00
|
|
|
"A trapped chest is a container which provides 27 inventory slots. When it is opened, it sends a redstone " ..
|
|
|
|
"signal to its adjacent blocks as long it stays open. Trapped chests can be turned into large trapped " ..
|
|
|
|
"chests with double the capacity by placing two trapped chests next to each other."
|
|
|
|
),
|
2024-06-21 15:22:26 +02:00
|
|
|
usagehelp = chestusage,
|
|
|
|
tt_help = S("27 inventory slots") ..
|
|
|
|
"\n" .. S("Can be combined to a large chest") .. "\n" .. S("Emits a redstone signal when opened"),
|
|
|
|
tiles = traptiles,
|
2024-06-22 12:05:08 +02:00
|
|
|
groups = {
|
|
|
|
handy = 1,
|
|
|
|
axey = 1,
|
|
|
|
material_wood = 1,
|
|
|
|
flammable = -1,
|
|
|
|
mesecon = 2,
|
|
|
|
},
|
2024-06-21 15:22:26 +02:00
|
|
|
sounds = mcl_sounds.node_sound_wood_defaults(),
|
|
|
|
hardness = 2.5,
|
|
|
|
hidden = false,
|
|
|
|
mesecons = {
|
2024-06-21 11:15:39 +02:00
|
|
|
receptor = {
|
|
|
|
state = mesecon.state.off,
|
|
|
|
rules = trapped_chest_mesecons_rules,
|
|
|
|
},
|
|
|
|
},
|
2024-06-21 15:22:26 +02:00
|
|
|
on_rightclick = function(pos, node, clicker)
|
2024-06-21 11:15:39 +02:00
|
|
|
minetest.swap_node(pos, { name = "mcl_chests:trapped_chest_on_small", param2 = node.param2 })
|
2024-06-21 13:43:12 +02:00
|
|
|
mcl_chests.find_or_create_entity(pos, "mcl_chests:trapped_chest_on_small", { "mcl_chests_trapped.png" },
|
|
|
|
node.param2, false, "default_chest", "mcl_chests_chest", "chest")
|
|
|
|
:reinitialize("mcl_chests:trapped_chest_on_small")
|
2024-06-21 11:15:39 +02:00
|
|
|
mesecon.receptor_on(pos, trapped_chest_mesecons_rules)
|
|
|
|
end,
|
2024-06-21 15:22:26 +02:00
|
|
|
on_rightclick_left = function(pos, node, clicker)
|
2024-06-21 11:15:39 +02:00
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
meta:set_int("players", 1)
|
|
|
|
|
|
|
|
minetest.swap_node(pos, { name = "mcl_chests:trapped_chest_on_left", param2 = node.param2 })
|
2024-06-21 13:43:12 +02:00
|
|
|
mcl_chests.find_or_create_entity(pos, "mcl_chests:trapped_chest_on_left",
|
|
|
|
mcl_chests.tiles.chest_trapped_double, node.param2, true, "default_chest", "mcl_chests_chest",
|
|
|
|
"chest"):reinitialize("mcl_chests:trapped_chest_on_left")
|
2024-06-21 11:15:39 +02:00
|
|
|
mesecon.receptor_on(pos, trapped_chest_mesecons_rules)
|
|
|
|
|
|
|
|
local pos_other = get_double_container_neighbor_pos(pos, node.param2, "left")
|
|
|
|
minetest.swap_node(pos_other, { name = "mcl_chests:trapped_chest_on_right", param2 = node.param2 })
|
|
|
|
mesecon.receptor_on(pos_other, trapped_chest_mesecons_rules)
|
|
|
|
end,
|
2024-06-21 15:22:26 +02:00
|
|
|
on_rightclick_right = function(pos, node, clicker)
|
2024-06-21 11:15:39 +02:00
|
|
|
local pos_other = get_double_container_neighbor_pos(pos, node.param2, "right")
|
|
|
|
|
|
|
|
minetest.swap_node(pos, { name = "mcl_chests:trapped_chest_on_right", param2 = node.param2 })
|
|
|
|
mesecon.receptor_on(pos, trapped_chest_mesecons_rules)
|
|
|
|
|
|
|
|
minetest.swap_node(pos_other, { name = "mcl_chests:trapped_chest_on_left", param2 = node.param2 })
|
2024-06-21 13:43:12 +02:00
|
|
|
mcl_chests.find_or_create_entity(pos_other, "mcl_chests:trapped_chest_on_left",
|
|
|
|
mcl_chests.tiles.chest_trapped_double, node.param2, true, "default_chest", "mcl_chests_chest",
|
|
|
|
"chest"):reinitialize("mcl_chests:trapped_chest_on_left")
|
2024-06-21 11:15:39 +02:00
|
|
|
mesecon.receptor_on(pos_other, trapped_chest_mesecons_rules)
|
|
|
|
end
|
2024-06-21 15:22:26 +02:00
|
|
|
})
|
2024-06-21 11:15:39 +02:00
|
|
|
|
2024-06-21 15:22:26 +02:00
|
|
|
mcl_chests.register_chest("trapped_chest_on", {
|
|
|
|
desc = nil,
|
|
|
|
longdesc = nil,
|
|
|
|
usagehelp = nil,
|
|
|
|
tt_help = nil,
|
|
|
|
tiles = traptiles,
|
2024-06-22 12:05:08 +02:00
|
|
|
groups = {
|
|
|
|
handy = 1,
|
|
|
|
axey = 1,
|
|
|
|
material_wood = 1,
|
|
|
|
flammable = -1,
|
|
|
|
mesecon = 2,
|
|
|
|
},
|
2024-06-21 15:22:26 +02:00
|
|
|
sounds = mcl_sounds.node_sound_wood_defaults(),
|
|
|
|
hardness = 2.5,
|
|
|
|
hidden = true,
|
|
|
|
mesecons = {
|
2024-06-21 11:15:39 +02:00
|
|
|
receptor = {
|
|
|
|
state = mesecon.state.on,
|
|
|
|
rules = trapped_chest_mesecons_rules,
|
|
|
|
},
|
|
|
|
},
|
2024-06-21 15:22:26 +02:00
|
|
|
on_rightclick = nil,
|
|
|
|
on_rightclick_left = nil,
|
|
|
|
on_rightclick_right = nil,
|
|
|
|
drop = "trapped_chest",
|
|
|
|
canonical_basename = "trapped_chest"
|
|
|
|
})
|
2024-06-21 11:15:39 +02:00
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "mcl_chests:chest",
|
|
|
|
recipe = {
|
|
|
|
{ "group:wood", "group:wood", "group:wood" },
|
|
|
|
{ "group:wood", "", "group:wood" },
|
|
|
|
{ "group:wood", "group:wood", "group:wood" },
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
type = "fuel",
|
|
|
|
recipe = "mcl_chests:chest",
|
|
|
|
burntime = 15,
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
type = "fuel",
|
|
|
|
recipe = "mcl_chests:trapped_chest",
|
|
|
|
burntime = 15,
|
|
|
|
})
|