Added locked chests made from mienrals

master
Kotolegokot 2013-04-26 20:45:36 +06:00
parent 63bc94f31c
commit b1939adb39
22 changed files with 100 additions and 0 deletions

View File

@ -142,6 +142,96 @@ for _, mineral in ipairs(decor_minerals) do
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
minetest.register_node("decorations:"..mineral[1].."_chest_locked", {
description = mineral[2].." Locked Chest",
tiles = {"decorations_"..mineral[1].."_chest_top.png", "decorations_"..mineral[1].."_chest_top.png", "decorations_"..mineral[1].."_chest_side.png",
"decorations_"..mineral[1].."_chest_side.png", "decorations_"..mineral[1].."_chest_side.png", "decorations_"..mineral[1].."_chest_lock.png"},
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
after_place_node = function(pos, placer)
local meta = minetest.env:get_meta(pos)
meta:set_string("owner", placer:get_player_name() or "")
meta:set_string("infotext", mineral[2].." Locked Chest (owned by "..
meta:get_string("owner")..")")
end,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("infotext", mineral[2].." Locked Chest")
meta:set_string("owner", "")
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
return inv:is_empty("main")
end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local meta = minetest.env:get_meta(pos)
if not has_locked_chest_privilege(meta, player) then
minetest.log("action", player:get_player_name()..
" tried to access a locked chest belonging to "..
meta:get_string("owner").." at "..
minetest.pos_to_string(pos))
return 0
end
return count
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.env:get_meta(pos)
if not has_locked_chest_privilege(meta, player) then
minetest.log("action", player:get_player_name()..
" tried to access a locked chest belonging to "..
meta:get_string("owner").." at "..
minetest.pos_to_string(pos))
return 0
end
return stack:get_count()
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
local meta = minetest.env:get_meta(pos)
if not has_locked_chest_privilege(meta, player) then
minetest.log("action", player:get_player_name()..
" tried to access a locked chest belonging to "..
meta:get_string("owner").." at "..
minetest.pos_to_string(pos))
return 0
end
return stack:get_count()
end,
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
minetest.log("action", player:get_player_name()..
" moves stuff in locked chest at "..minetest.pos_to_string(pos))
end,
on_metadata_inventory_put = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name()..
" moves stuff to locked chest at "..minetest.pos_to_string(pos))
end,
on_metadata_inventory_take = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name()..
" takes stuff from locked chest at "..minetest.pos_to_string(pos))
end,
on_rightclick = function(pos, node, clicker)
local meta = minetest.env:get_meta(pos)
if has_locked_chest_privilege(meta, clicker) then
local pos = pos.x .. "," .. pos.y .. "," ..pos.z
minetest.show_formspec(clicker:get_player_name(),
"decorations:locked_chest",
"size[8,9]"..
"list[nodemeta:".. pos .. ";main;0,0;8,4;]"..
"list[current_player;main;0,5;8,4;]")
end
end,
})
minetest.register_node("decorations:"..mineral[1].."_cylinder", {
description = mineral[2].." Cylinder",
drawtype = "nodebox",
@ -207,6 +297,15 @@ for _, mineral in ipairs(decor_minerals) do
{"minerals:"..mineral[1],"minerals:"..mineral[1],"minerals:"..mineral[1]},
}
})
minetest.register_craft({
output = "decorations:"..mineral[1].."_chest_locked 2",
recipe = {
{"minerals:"..mineral[1],"minerals:"..mineral[1],"minerals:"..mineral[1]},
{"minerals:"..mineral[1],"group:lock","minerals:"..mineral[1]},
{"minerals:"..mineral[1],"minerals:"..mineral[1],"minerals:"..mineral[1]},
}
})
minetest.register_craft({
output = "decorations:"..mineral[1].."_block",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 749 B

After

Width:  |  Height:  |  Size: 719 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 762 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 475 B

After

Width:  |  Height:  |  Size: 504 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 546 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 491 B

After

Width:  |  Height:  |  Size: 524 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 573 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 705 B

After

Width:  |  Height:  |  Size: 679 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 719 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 740 B

After

Width:  |  Height:  |  Size: 748 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 808 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 715 B

After

Width:  |  Height:  |  Size: 697 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 806 B

After

Width:  |  Height:  |  Size: 767 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 810 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 674 B

After

Width:  |  Height:  |  Size: 585 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 633 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 706 B

After

Width:  |  Height:  |  Size: 627 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 672 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 782 B

After

Width:  |  Height:  |  Size: 727 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

View File

@ -97,6 +97,7 @@ for i=1, #metals.list do
minetest.register_craftitem("metals:"..metals.list[i].."_lock", {
description = metals.desc_list[i].." Lock",
inventory_image = "metals_"..metals.list[i].."_lock.png",
groups = {lock=1}
})
--