Add title field for mcl_chests.register_chest

This commit is contained in:
Mikita Wiśniewski 2024-06-22 21:37:32 +07:00 committed by the-real-herowl
parent b4b5bf8391
commit 6bbb6b8dec
4 changed files with 61 additions and 3 deletions

View file

@ -495,6 +495,11 @@ function mcl_chests.register_chest(basename, d)
-- If this passes without crash, we know for a fact that d = {...} -- If this passes without crash, we know for a fact that d = {...}
assert((d and type(d) == "table"), "Second argument to mcl_chests.register_chest must be a table") assert((d and type(d) == "table"), "Second argument to mcl_chests.register_chest must be a table")
-- Fallback for when there is no `title` field
if not d.title then d.title = {} end
d.title.small = d.title.small or d.desc
d.title.double = d.title.double or ("Large " .. d.title.small)
if not d.drop then if not d.drop then
d.drop = "mcl_chests:" .. basename d.drop = "mcl_chests:" .. basename
else else
@ -686,7 +691,7 @@ function mcl_chests.register_chest(basename, d)
end end
local name = minetest.get_meta(pos):get_string("name") local name = minetest.get_meta(pos):get_string("name")
if name == "" then if name == "" then
name = S("Chest") name = d.title.small
end end
minetest.show_formspec(clicker:get_player_name(), minetest.show_formspec(clicker:get_player_name(),
@ -777,7 +782,7 @@ function mcl_chests.register_chest(basename, d)
if name == "" then -- if empty after that ^ if name == "" then -- if empty after that ^
name = minetest.get_meta(pos_other):get_string("name") name = minetest.get_meta(pos_other):get_string("name")
end if name == "" then -- if STILL empty after that ^ end if name == "" then -- if STILL empty after that ^
name = S("Large Chest") name = d.title.double
end end
minetest.show_formspec(clicker:get_player_name(), minetest.show_formspec(clicker:get_player_name(),
@ -872,7 +877,7 @@ function mcl_chests.register_chest(basename, d)
if name == "" then -- if empty after that ^ if name == "" then -- if empty after that ^
name = minetest.get_meta(pos_other):get_string("name") name = minetest.get_meta(pos_other):get_string("name")
end if name == "" then -- if STILL empty after that ^ end if name == "" then -- if STILL empty after that ^
name = S("Large Chest") name = d.title.double
end end
minetest.show_formspec(clicker:get_player_name(), minetest.show_formspec(clicker:get_player_name(),

View file

@ -39,6 +39,10 @@ local traptiles = {
mcl_chests.register_chest("trapped_chest", { mcl_chests.register_chest("trapped_chest", {
desc = S("Trapped Chest"), desc = S("Trapped Chest"),
title = {
small = S("Chest"),
double = S("Large Chest")
},
longdesc = S( longdesc = S(
"A trapped chest is a container which provides 27 inventory slots. When it is opened, it sends a redstone " .. "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 " .. "signal to its adjacent blocks as long it stays open. Trapped chests can be turned into large trapped " ..
@ -101,6 +105,10 @@ mcl_chests.register_chest("trapped_chest", {
mcl_chests.register_chest("trapped_chest_on", { mcl_chests.register_chest("trapped_chest_on", {
desc = nil, desc = nil,
title = {
small = S("Chest"),
double = S("Large Chest")
},
longdesc = nil, longdesc = nil,
usagehelp = nil, usagehelp = nil,
tt_help = nil, tt_help = nil,

View file

@ -0,0 +1,44 @@
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
mcl_chests.register_chest("stone_chest", {
desc = S("Stone Chest"),
large_desc = S("Large Stone Chest"),
longdesc = S(
"Stone Chests are containers which provide 27 inventory slots. Stone Chests can be turned into" ..
"large stone chests with double the capacity by placing two stone chests next to each other."
),
usagehelp = S("To access its inventory, rightclick it. When broken, the items will drop out."),
tt_help = S("27 inventory slots") .. "\n" .. S("Can be combined to a large stone chest"),
tiles = {
small = { mcl_chests.tiles.chest_normal_small[1] .. "^[hsl:-15:-80:-20" },
double = { mcl_chests.tiles.chest_normal_double[1] .. "^[hsl:-15:-80:-20" },
inv = { "default_chest_top.png^[hsl:-15:-80:-20",
"mcl_chests_chest_bottom.png^[hsl:-15:-80:-20",
"mcl_chests_chest_right.png^[hsl:-15:-80:-20",
"mcl_chests_chest_left.png^[hsl:-15:-80:-20",
"mcl_chests_chest_back.png^[hsl:-15:-80:-20",
"default_chest_front.png^[hsl:-15:-80:-20"
},
},
groups = {
pickaxey = 1,
stone = 1,
material_stone = 1,
},
sounds = mcl_sounds.node_sound_stone_defaults(),
hardness = 4.0,
hidden = false,
})
minetest.register_craft({
output = "mcl_chests:stone_chest",
recipe = {
{ "mcl_core:stone", "mcl_core:stone", "mcl_core:stone" },
{ "mcl_core:stone", "", "mcl_core:stone" },
{ "mcl_core:stone", "mcl_core:stone", "mcl_core:stone" },
},
})

View file

@ -41,6 +41,7 @@ dofile(modpath .. "/api.lua")
dofile(modpath .. "/chests.lua") dofile(modpath .. "/chests.lua")
dofile(modpath .. "/ender.lua") dofile(modpath .. "/ender.lua")
dofile(modpath .. "/shulkers.lua") dofile(modpath .. "/shulkers.lua")
--dofile(modpath .. "/example.lua")