Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.35 KB | None | 0 0
  1. -- This file supplies refrigerators
  2.  
  3. minetest.register_node('homedecor:refrigerator', {
  4.     drawtype = "nodebox",
  5.     description = "Refrigerator",
  6.     tiles = {
  7.         'homedecor_refrigerator_top.png',
  8.         'homedecor_refrigerator_bottom.png',
  9.         'homedecor_refrigerator_right.png',
  10.         'homedecor_refrigerator_left.png',
  11.         'homedecor_refrigerator_back.png', 
  12.         'homedecor_refrigerator_front.png'
  13.     },
  14.     inventory_image = "homedecor_refrigerator_inv.png",
  15.     sunlight_propagates = false,
  16.     paramtype = "light",
  17.     paramtype2 = "facedir",
  18.     walkable = true,
  19.     groups = { snappy = 3 },
  20.  
  21.         selection_box = {
  22.                 type = "fixed",
  23.                 fixed = { -0.5, -0.5, -0.5, 0.5, 1.5, 0.5 }
  24.         },
  25.         node_box = {
  26.                 type = "fixed",
  27.                 fixed = { -0.5, -0.5, -0.5, 0.5, 1.5, 0.5 }
  28.         },
  29.  
  30.     sounds = default.node_sound_leaves_defaults(),
  31.     on_construct = function(pos)
  32.         local meta = minetest.env:get_meta(pos)
  33.         meta:set_string("formspec",
  34.                 "size[10,10]"..
  35.                 "list[current_name;main;0,0;10,5;]"..
  36.                 "list[current_player;main;1,6;8,4;]")
  37.         meta:set_string("infotext", "Refrigerator")
  38.         local inv = meta:get_inventory()
  39.         inv:set_size("main",50)
  40.     end,
  41.  
  42.     after_place_node = function(pos, placer)
  43.         ntop = minetest.env:get_node({x=pos.x, y=pos.y+1, z=pos.z})
  44.         if ntop.name ~= "air" then
  45.             minetest.env:remove_node(pos)
  46.             placer:get_inventory():add_item("main", "homedecor:refrigerator")
  47.                     minetest.chat_send_player( placer:get_player_name(), 'Not enough vertical space to place a refrigerator!' )
  48.         end
  49.     end,
  50.  
  51.     can_dig = function(pos,player)
  52.         local meta = minetest.env:get_meta(pos);
  53.         local inv = meta:get_inventory()
  54.         return inv:is_empty("main")
  55.     end,
  56.     on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
  57.         minetest.log("action", player:get_player_name()..
  58.                 " moves stuff in refrigerator at "..minetest.pos_to_string(pos))
  59.     end,
  60.     on_metadata_inventory_put = function(pos, listname, index, stack, player)
  61.         minetest.log("action", player:get_player_name()..
  62.                 " moves stuff to refrigerator at "..minetest.pos_to_string(pos))
  63.     end,
  64.     on_metadata_inventory_take = function(pos, listname, index, stack, player)
  65.         minetest.log("action", player:get_player_name()..
  66.                 " takes stuff from refrigerator at "..minetest.pos_to_string(pos))
  67.     end,
  68. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement