mirror of
https://github.com/luanti-org/minetest_game.git
synced 2025-05-21 14:53:16 -04:00
chests: Do not hardcode "default:".
This allows other mods to greater use the default.chest functions. Fixes https://github.com/minetest/minetest_game/issues/1936 v2: Keep the default formspec name. v3: Remove unnecessary backwards compatibility. v4: register_lbm only applies to "default:chest" and "default:chest_locked".
This commit is contained in:
parent
695f98f213
commit
b82cd9dd08
1 changed files with 27 additions and 24 deletions
|
@ -44,7 +44,7 @@ function default.chest.chest_lid_close(pn)
|
|||
end
|
||||
|
||||
local node = minetest.get_node(pos)
|
||||
minetest.after(0.2, minetest.swap_node, pos, { name = "default:" .. swap,
|
||||
minetest.after(0.2, minetest.swap_node, pos, { name = swap,
|
||||
param2 = node.param2 })
|
||||
minetest.sound_play(sound, {gain = 0.3, pos = pos,
|
||||
max_hear_distance = 10}, true)
|
||||
|
@ -132,7 +132,7 @@ function default.chest.register_chest(name, d)
|
|||
pos = pos, max_hear_distance = 10}, true)
|
||||
if not default.chest.chest_lid_obstructed(pos) then
|
||||
minetest.swap_node(pos,
|
||||
{ name = "default:" .. name .. "_open",
|
||||
{ name = name .. "_open",
|
||||
param2 = node.param2 })
|
||||
end
|
||||
minetest.after(0.2, minetest.show_formspec,
|
||||
|
@ -203,7 +203,7 @@ function default.chest.register_chest(name, d)
|
|||
max_hear_distance = 10}, true)
|
||||
if not default.chest.chest_lid_obstructed(pos) then
|
||||
minetest.swap_node(pos, {
|
||||
name = "default:" .. name .. "_open",
|
||||
name = name .. "_open",
|
||||
param2 = node.param2 })
|
||||
end
|
||||
minetest.after(0.2, minetest.show_formspec,
|
||||
|
@ -215,7 +215,7 @@ function default.chest.register_chest(name, d)
|
|||
def.on_blast = function(pos)
|
||||
local drops = {}
|
||||
default.get_inventory_drops(pos, "main", drops)
|
||||
drops[#drops+1] = "default:" .. name
|
||||
drops[#drops+1] = name
|
||||
minetest.remove_node(pos)
|
||||
return drops
|
||||
end
|
||||
|
@ -248,7 +248,7 @@ function default.chest.register_chest(name, d)
|
|||
def_opened.tiles[i].backface_culling = true
|
||||
end
|
||||
end
|
||||
def_opened.drop = "default:" .. name
|
||||
def_opened.drop = name
|
||||
def_opened.groups.not_in_creative_inventory = 1
|
||||
def_opened.selection_box = {
|
||||
type = "fixed",
|
||||
|
@ -265,14 +265,16 @@ function default.chest.register_chest(name, d)
|
|||
def_closed.tiles[5] = def.tiles[3] -- drawtype to make them match the mesh
|
||||
def_closed.tiles[3] = def.tiles[3].."^[transformFX"
|
||||
|
||||
minetest.register_node("default:" .. name, def_closed)
|
||||
minetest.register_node("default:" .. name .. "_open", def_opened)
|
||||
minetest.register_node(name, def_closed)
|
||||
minetest.register_node(name .. "_open", def_opened)
|
||||
|
||||
-- convert old chests to this new variant
|
||||
if name == "default:chest" or name == "default:chest_locked" then
|
||||
local itemname = string.match(name, ":(.*)")
|
||||
minetest.register_lbm({
|
||||
label = "update chests to opening chests",
|
||||
name = "default:upgrade_" .. name .. "_v2",
|
||||
nodenames = {"default:" .. name},
|
||||
name = "default:upgrade_" .. itemname .. "_v2",
|
||||
nodenames = {name},
|
||||
action = function(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec", nil)
|
||||
|
@ -285,9 +287,10 @@ function default.chest.register_chest(name, d)
|
|||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
default.chest.register_chest("chest", {
|
||||
default.chest.register_chest("default:chest", {
|
||||
description = S("Chest"),
|
||||
tiles = {
|
||||
"default_chest_top.png",
|
||||
|
@ -303,7 +306,7 @@ default.chest.register_chest("chest", {
|
|||
groups = {choppy = 2, oddly_breakable_by_hand = 2},
|
||||
})
|
||||
|
||||
default.chest.register_chest("chest_locked", {
|
||||
default.chest.register_chest("default:chest_locked", {
|
||||
description = S("Locked Chest"),
|
||||
tiles = {
|
||||
"default_chest_top.png",
|
||||
|
|
Loading…
Add table
Reference in a new issue