1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-12-25 18:20:36 +01:00

Updated connected_chests

This commit is contained in:
LeMagnesium 2015-04-20 21:38:10 +02:00
parent 336359e038
commit 58c6d48d9c
4 changed files with 169 additions and 92 deletions

View File

@ -1 +1,3 @@
default default
pipeworks?
technic?

View File

@ -113,6 +113,9 @@ end
local function return_remove_next(allowed_name) local function return_remove_next(allowed_name)
local function remove_next(pos, oldnode) local function remove_next(pos, oldnode)
if oldnode.param2 > 3 then
return
end
local x, z = unpack(string.split(param_tab2[oldnode.param2], " ")) local x, z = unpack(string.split(param_tab2[oldnode.param2], " "))
pos.x = pos.x-x pos.x = pos.x-x
pos.z = pos.z-z pos.z = pos.z-z
@ -123,79 +126,95 @@ local function return_remove_next(allowed_name)
return remove_next return remove_next
end end
local function return_add_next(right_name)
local function add_next(pos, node)
node = node or minetest.get_node(pos)
local par = node.param2
if par > 3 then
node.param2 = 0
minetest.set_node(pos, node)
return
end
local x, z = unpack(string.split(param_tab2[par], " "))
pos.x = pos.x-x
pos.z = pos.z-z
if minetest.get_node(pos).name == "air" then
minetest.set_node(pos, {name=right_name, param2=par})
end
end
return add_next
end
local function log_access(pos, player, text) local function log_access(pos, player, text)
minetest.log("action", player:get_player_name().. minetest.log("action", player:get_player_name()..
" moves stuff "..text.." at "..minetest.pos_to_string(pos)) " moves stuff "..text.." at "..minetest.pos_to_string(pos))
end end
local default_chest = minetest.registered_nodes["default:chest"]
minetest.register_node("connected_chests:chest_left", { -- Adds the big chests
tiles = {"connected_chests_top.png", "connected_chests_top.png", "default_obsidian_glass.png",
"default_chest_side.png", "connected_chests_side.png^[transformFX", "connected_chests_side.png^connected_chests_front.png"}, local top_texture = "connected_chests_top.png^default_chest_top.png^([combine:16x16:5,0=default_chest_top.png^connected_chests_frame.png^[makealpha:255,126,126)^connected_chests_top.png"
paramtype2 = "facedir", local side_texture = "connected_chests_side.png^default_chest_side.png^([combine:16x16:5,0=default_chest_side.png^connected_chests_frame.png^[makealpha:255,126,126)^connected_chests_side.png"
drop = "default:chest 2",
groups = default_chest.groups, local chest = table.copy(minetest.registered_nodes["default:chest"])
is_ground_content = default_chest.is_ground_content, chest.description = nil
sounds = default_chest.sounds, chest.legacy_facedir_simple = nil
selection_box = { chest.after_place_node = nil
chest.on_receive_fields = nil
chest.tiles = {top_texture, top_texture, "default_obsidian_glass.png",
"default_chest_side.png", side_texture.."^[transformFX", side_texture.."^connected_chests_front.png"}
chest.drop = "default:chest 2"
chest.selection_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
{-0.5, -0.5, -0.5, 1.5, 0.5, 0.5}, {-0.5, -0.5, -0.5, 1.5, 0.5, 0.5},
}, },
}, }
can_dig = default_chest.can_dig, chest.on_construct = return_add_next("connected_chests:chest_right")
after_dig_node = return_remove_next("connected_chests:chest_right"), chest.after_destruct = return_remove_next("connected_chests:chest_right")
on_metadata_inventory_move = function(pos, _, _, _, _, _, player) chest.on_metadata_inventory_move = function(pos, _, _, _, _, _, player)
log_access(pos, player, "in a big chest") log_access(pos, player, "in a big chest")
end, end
on_metadata_inventory_put = function(pos, _, _, _, player) chest.on_metadata_inventory_put = function(pos, _, _, _, player)
log_access(pos, player, "to a big chest") log_access(pos, player, "to a big chest")
end, end
on_metadata_inventory_take = function(pos, _, _, _, player) chest.on_metadata_inventory_take = function(pos, _, _, _, player)
log_access(pos, player, "from a big chest") log_access(pos, player, "from a big chest")
end,
})
local function has_locked_chest_privilege(meta, player)
if player:get_player_name() ~= meta:get_string("owner") then
return false
end
return true
end end
local default_chest_locked = minetest.registered_nodes["default:chest_locked"] minetest.register_node("connected_chests:chest_left", chest)
minetest.register_node("connected_chests:chest_locked_left", {
tiles = {"connected_chests_top.png", "connected_chests_top.png", "default_obsidian_glass.png",
"default_chest_side.png", "connected_chests_side.png^[transformFX", "connected_chests_side.png^connected_chests_lock.png"}, local chest_locked = table.copy(minetest.registered_nodes["default:chest_locked"])
paramtype2 = "facedir", chest_locked.description = nil
drop = "default:chest_locked 2", chest_locked.legacy_facedir_simple = nil
groups = default_chest_locked.groups, chest_locked.after_place_node = nil
is_ground_content = default_chest_locked.is_ground_content, chest_locked.on_construct = nil
sounds = default_chest_locked.sounds, chest_locked.on_receive_fields = nil
selection_box = { chest_locked.tiles = {top_texture, top_texture, "default_obsidian_glass.png",
"default_chest_side.png", side_texture.."^[transformFX", side_texture.."^connected_chests_front.png^connected_chests_lock.png"}
chest_locked.drop = "default:chest_locked 2"
chest_locked.selection_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
{-0.5, -0.5, -0.5, 1.5, 0.5, 0.5}, {-0.5, -0.5, -0.5, 1.5, 0.5, 0.5},
}, },
}, }
can_dig = default_chest_locked.can_dig, chest_locked.on_construct = return_add_next("connected_chests:chest_locked_right")
after_dig_node = return_remove_next("connected_chests:chest_locked_right"), chest_locked.after_destruct = return_remove_next("connected_chests:chest_locked_right")
allow_metadata_inventory_move = default_chest_locked.allow_metadata_inventory_move, chest_locked.on_metadata_inventory_move = function(pos, _, _, _, _, _, player)
allow_metadata_inventory_put = default_chest_locked.allow_metadata_inventory_put,
allow_metadata_inventory_take = default_chest_locked.allow_metadata_inventory_take,
on_metadata_inventory_move = function(pos, _, _, _, _, _, player)
log_access(pos, player, "in a big locked chest") log_access(pos, player, "in a big locked chest")
end, end
on_metadata_inventory_put = function(pos, _, _, _, player) chest_locked.on_metadata_inventory_put = function(pos, _, _, _, player)
log_access(pos, player, "to a big locked chest") log_access(pos, player, "to a big locked chest")
end, end
on_metadata_inventory_take = function(pos, _, _, _, player) chest_locked.on_metadata_inventory_take = function(pos, _, _, _, player)
log_access(pos, player, "from a big locked chest") log_access(pos, player, "from a big locked chest")
end, end
on_rightclick = function(pos, _, clicker) chest_locked.on_rightclick = function(pos, _, clicker)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
if has_locked_chest_privilege(meta, clicker) then if clicker:get_player_name() == meta:get_string("owner") then
minetest.show_formspec( minetest.show_formspec(
clicker:get_player_name(), clicker:get_player_name(),
"connected_chests:chest_locked_left", "connected_chests:chest_locked_left",
@ -204,35 +223,97 @@ minetest.register_node("connected_chests:chest_locked_left", {
"list[current_player;main;2.5,5.2;8,4;]" "list[current_player;main;2.5,5.2;8,4;]"
) )
end end
end, end
})
minetest.register_node("connected_chests:chest_locked_left", chest_locked)
minetest.register_node("connected_chests:chest_right", { minetest.register_node("connected_chests:chest_right", {
tiles = {"connected_chests_top.png^[transformFX", "connected_chests_top.png^[transformFX", "default_chest_side.png", tiles = {top_texture.."^[transformFX", top_texture.."^[transformFX", "default_chest_side.png",
"default_obsidian_glass.png", "connected_chests_side.png", "connected_chests_side.png^connected_chests_front.png^[transformFX"}, "default_obsidian_glass.png", side_texture, side_texture.."^connected_chests_front.png^[transformFX"},
paramtype2 = "facedir", paramtype2 = "facedir",
drop = "", drop = "",
pointable = false, pointable = false,
diggable = false, diggable = false,
on_construct = function(pos)
local node = minetest.get_node(pos)
if node.param2 > 3 then
node.param2 = node.param2%4
minetest.set_node(pos, node)
return
end
local x, z = unpack(string.split(param_tab2[node.param2], " "))
local node_left = minetest.get_node({x=pos.x+x, y=pos.y, z=pos.z+z})
if node_left.name ~= "connected_chests:chest_left"
or node_left.param2 ~= node.param2 then
minetest.remove_node(pos)
end
end,
after_destruct = function(pos, oldnode)
if oldnode.param2 > 3 then
return
end
local x, z = unpack(string.split(param_tab2[oldnode.param2], " "))
local node_left = minetest.get_node({x=pos.x+x, y=pos.y, z=pos.z+z})
if node_left.name == "connected_chests:chest_left"
and node_left.param2 == oldnode.param2
and minetest.get_node(pos).name == "air" then
minetest.set_node(pos, oldnode)
end
end
}) })
minetest.register_node("connected_chests:chest_locked_right", { minetest.register_node("connected_chests:chest_locked_right", {
tiles = {"connected_chests_top.png^[transformFX", "connected_chests_top.png^[transformFX", "default_chest_side.png", tiles = {top_texture.."^[transformFX", top_texture.."^[transformFX", "default_chest_side.png",
"default_obsidian_glass.png", "connected_chests_side.png", "connected_chests_side.png^connected_chests_lock.png^[transformFX"}, "default_obsidian_glass.png", side_texture, side_texture.."^connected_chests_front.png^connected_chests_lock.png^[transformFX"},
paramtype2 = "facedir", paramtype2 = "facedir",
drop = "", drop = "",
pointable = false, pointable = false,
diggable = false, diggable = false,
on_construct = function(pos)
local node = minetest.get_node(pos)
if node.param2 > 3 then
node.param2 = node.param2%4
minetest.set_node(pos, node)
return
end
local x, z = unpack(string.split(param_tab2[node.param2], " "))
local node_left = minetest.get_node({x=pos.x+x, y=pos.y, z=pos.z+z})
if node_left.name ~= "connected_chests:chest_locked_left"
or node_left.param2 ~= node.param2 then
minetest.remove_node(pos)
end
end,
after_destruct = function(pos, oldnode)
if oldnode.param2 > 3 then
return
end
local x, z = unpack(string.split(param_tab2[oldnode.param2], " "))
local node_left = minetest.get_node({x=pos.x+x, y=pos.y, z=pos.z+z})
if node_left.name == "connected_chests:chest_locked_left"
and node_left.param2 == oldnode.param2
and minetest.get_node(pos).name == "air" then
minetest.set_node(pos, oldnode)
end
end
}) })
-- abms to fix half chests
for _,i in pairs({"chest", "chest_locked"}) do for _,i in pairs({"chest", "chest_locked"}) do
minetest.register_abm ({ minetest.register_abm ({
nodenames = {"connected_chests:"..i.."_right"}, nodenames = {"connected_chests:"..i.."_right"},
interval = 3, interval = 10,
chance = 1, chance = 1,
action = function (pos, node) action = function (pos, node)
if node.param2 > 3 then
node.param2 = node.param2%4
minetest.set_node(pos, node)
return
end
local x, z = unpack(string.split(param_tab2[node.param2], " ")) local x, z = unpack(string.split(param_tab2[node.param2], " "))
if minetest.get_node({x=pos.x+x, y=pos.y, z=pos.z+z}).name ~= "connected_chests:"..i.."_left" then local left_node = minetest.get_node({x=pos.x+x, y=pos.y, z=pos.z+z})
if left_node.name ~= "connected_chests:"..i.."_left"
or left_node.param2 ~= node.param2 then
minetest.remove_node(pos) minetest.remove_node(pos)
end end
end, end,
@ -241,14 +322,7 @@ for _,i in pairs({"chest", "chest_locked"}) do
nodenames = {"connected_chests:"..i.."_left"}, nodenames = {"connected_chests:"..i.."_left"},
interval = 3, interval = 3,
chance = 1, chance = 1,
action = function (pos, node) action = return_add_next("connected_chests:"..i.."_right"),
local par = node.param2
local x, z = unpack(string.split(param_tab2[par], " "))
pos = {x=pos.x-x, y=pos.y, z=pos.z-z}
if minetest.get_node(pos).name == "air" then
minetest.set_node(pos, {name="connected_chests:"..i.."_right", param2=par})
end
end,
}) })
end end

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 B

View File

@ -7,10 +7,11 @@ MAJ de "whoison" (la commande "/timeonline <pseudo>" peut aussi être utilisé d
MAJ de "mobs" (ajout des chèvres/goats) MAJ de "mobs" (ajout des chèvres/goats)
---??/??/2015--- (Remerciements : Mg) ---??/??/2015--- (Remerciements : Mg)
MaJ de "default" (ajout de default:river_water_*) MAJ de "connected_chests"
MaJ de "irc" MAJ de "default" (ajout de default:river_water_*)
MaJ de "homedecor" MAJ de "irc"
MaJ de "metatools" MAJ de "homedecor"
MAJ de "metatools"
Ajout du mod "connected_chests" (permet de fusionner deux chests, il suffit de placer le second en cliquant droit sur le côté du premier avec sneak enfoncé) Ajout du mod "connected_chests" (permet de fusionner deux chests, il suffit de placer le second en cliquant droit sur le côté du premier avec sneak enfoncé)
---13/04/2015--- (Remerciements : Crabman, Mg) ---13/04/2015--- (Remerciements : Crabman, Mg)