Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- minetest.register_node("protection_chest:chest", {
- description = "Protection Chest",
- tiles = {
- "default_chest_top.png",
- "default_chest_top.png",
- "default_chest_side.png",
- "default_chest_side.png",
- "default_chest_lock.png",
- "default_chest_inside.png"
- },
- sounds = default.node_sound_wood_defaults(),
- groups = {choppy = 2, oddly_breakable_by_hand = 2},
- on_construct = function(pos)
- local meta = minetest.get_meta(pos)
- meta:set_string("infotext", "Protection Chest")
- meta:set_string("owner", "")
- local inv = meta:get_inventory()
- inv:set_size("main", 8*4)
- end
- -- after_place_node = function(pos, placer)
- -- local meta = minetest.get_meta(pos)
- -- meta:set_string("owner", placer:get_player_name() or "")
- -- meta:set_string("infotext", "Protection Chest (placed by " ..
- -- meta:get_string("owner") .. ")")
- -- end
- can_dig = function(pos,player)
- local meta = minetest.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)
- return count
- end
- allow_metadata_inventory_put = function(pos, listname, index, stack, player)
- return stack:get_count()
- end
- on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
- local name = clicker:get_player_name()
- if minetest.is_protected(pos,name) then
- minetest.chat_send_all(name,"You cannot use this shared chest, because you are not part of the protection.")
- return itemstack
- end
- local spos = pos.x .. "," .. pos.y .. "," .. pos.z
- local formspec = "size[8,9]" ..
- default.gui_bg ..
- default.gui_bg_img ..
- default.gui_slots ..
- "list[nodemeta:" .. spos .. ";main;0,0.3;8,4;]" ..
- "list[current_player;main;0,4.85;8,1;]" ..
- "list[current_player;main;0,6.08;8,3;8]" ..
- "listring[nodemeta:" .. spos .. ";main]" ..
- "listring[current_player;main]" ..
- default.get_hotbar_bg(0,4.85)
- minetest.after(0.2, minetest.show_formspec,name,"default:chest", get_chest_formspec(pos))
- end
- })
- minetest.register_craft({
- output = 'default:chest_shared',
- recipe = {
- {'default:chest', 'default:steel_ingot', 'default:steel_ingot'},
- {'', '', ''},
- {'', '', ''},
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement