Advertisement
Guest User

Untitled

a guest
Aug 9th, 2017
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.98 KB | None | 0 0
  1. minetest.register_node("protection_chest:chest", {
  2.  
  3. description = "Protection Chest",
  4.         tiles = {
  5.                 "default_chest_top.png",
  6.                 "default_chest_top.png",
  7.                 "default_chest_side.png",
  8.                 "default_chest_side.png",
  9.                 "default_chest_lock.png",
  10.                 "default_chest_inside.png"
  11.         },
  12.         sounds = default.node_sound_wood_defaults(),
  13.         groups = {choppy = 2, oddly_breakable_by_hand = 2},
  14.  
  15. on_construct = function(pos)
  16.                         local meta = minetest.get_meta(pos)
  17.                         meta:set_string("infotext", "Protection Chest")
  18.                         meta:set_string("owner", "")
  19.                         local inv = meta:get_inventory()
  20.                         inv:set_size("main", 8*4)
  21.                 end
  22. --                after_place_node = function(pos, placer)
  23. --                        local meta = minetest.get_meta(pos)
  24. --                        meta:set_string("owner", placer:get_player_name() or "")
  25. --                        meta:set_string("infotext", "Protection Chest (placed by " ..
  26. --                                        meta:get_string("owner") .. ")")
  27. --                end
  28.                 can_dig = function(pos,player)
  29.                         local meta = minetest.get_meta(pos);
  30.                         local inv = meta:get_inventory()
  31.                         return inv:is_empty("main")
  32.                 end
  33.                 allow_metadata_inventory_move = function(pos, from_list, from_index,
  34.                                 to_list, to_index, count, player)
  35.                         return count
  36.                 end
  37.                 allow_metadata_inventory_put = function(pos, listname, index, stack, player)
  38.                         return stack:get_count()
  39.                 end
  40.  
  41. on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
  42.  
  43. local name = clicker:get_player_name()
  44.  
  45. if minetest.is_protected(pos,name) then
  46. minetest.chat_send_all(name,"You cannot use this shared chest, because you are not part of the protection.")
  47. return itemstack
  48. end
  49.  
  50. local spos = pos.x .. "," .. pos.y .. "," .. pos.z
  51.  
  52. local formspec = "size[8,9]" ..
  53.                 default.gui_bg ..
  54.                 default.gui_bg_img ..
  55.                 default.gui_slots ..
  56.                 "list[nodemeta:" .. spos .. ";main;0,0.3;8,4;]" ..
  57.                 "list[current_player;main;0,4.85;8,1;]" ..
  58.                 "list[current_player;main;0,6.08;8,3;8]" ..
  59.                 "listring[nodemeta:" .. spos .. ";main]" ..
  60.                 "listring[current_player;main]" ..
  61.                 default.get_hotbar_bg(0,4.85)
  62.  
  63. minetest.after(0.2, minetest.show_formspec,name,"default:chest", get_chest_formspec(pos))
  64. end
  65.  
  66. })
  67.  
  68. minetest.register_craft({
  69.         output = 'default:chest_shared',
  70.         recipe = {
  71.                 {'default:chest', 'default:steel_ingot', 'default:steel_ingot'},
  72.                 {'', '', ''},
  73.                 {'', '', ''},
  74.         }
  75. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement