storage.lua 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. minetest.register_node('furniture:chest_small', {
  2. _doc_items_crafting = 'This is crafted in the Woodworking Station.',
  3. description = 'Small Chest',
  4. drawtype = 'mesh',
  5. mesh = 'furniture_chest_small.obj',
  6. tiles = {'furniture_chest_small.png'},
  7. overlay_tiles = {{name='furniture_chest_small_overlay.png', color='white'}},
  8. paramtype = 'light',
  9. paramtype2 = 'colorfacedir',
  10. palette = 'furniture_stain_palette.png',
  11. selection_box = {
  12. type = 'fixed',
  13. fixed = {-.4, -.5, -.3, .4, .2, .4},
  14. },
  15. collision_box = {
  16. type = 'fixed',
  17. fixed = {-.4, -.5, -.3, .4, .2, .4},
  18. },
  19. groups = {oddly_breakable_by_hand = 2, choppy=3, stainable=1},
  20. on_construct = function(pos)
  21. local meta = minetest.get_meta(pos)
  22. meta:set_string('formspec', furniture.storage_24_form(pos, ''))
  23. local inv = meta:get_inventory()
  24. inv:set_size('main', 24)
  25. end,
  26. can_dig = function(pos,player)
  27. local meta = minetest.get_meta(pos)
  28. local inv = meta:get_inventory()
  29. return inv:is_empty('main')
  30. end,
  31. on_receive_fields = function(pos, formname, fields, sender)
  32. local player_name = sender:get_player_name()
  33. if minetest.is_protected(pos, player_name) and not minetest.check_player_privs(sender, 'protection_bypass') then
  34. return
  35. end
  36. local meta = minetest.get_meta(pos)
  37. if fields ['save'] then
  38. meta:set_string('infotext', fields.description)
  39. meta:set_string('formspec', furniture.storage_24_form(pos, fields.description))
  40. elseif fields ['sort'] then
  41. furniture.sort_inventory(meta:get_inventory())
  42. end
  43. end,
  44. allow_metadata_inventory_put = furniture.inv_take_put,
  45. allow_metadata_inventory_take = furniture.inv_take_put,
  46. allow_metadata_inventory_move = furniture.inv_manipulate,
  47. on_metadata_inventory_put = furniture.inv_put,
  48. on_metadata_inventory_take = furniture.inv_take,
  49. })
  50. minetest.register_node('furniture:chest', {
  51. _doc_items_crafting = 'This is crafted in the Woodworking Station.',
  52. description = 'Chest',
  53. drawtype = 'mesh',
  54. mesh = 'furniture_chest.obj',
  55. tiles = {'furniture_chest.png'},
  56. overlay_tiles = {{name='furniture_chest_overlay.png', color='white'}},
  57. paramtype = 'light',
  58. paramtype2 = 'colorfacedir',
  59. palette = 'furniture_stain_palette.png',
  60. selection_box = {
  61. type = 'fixed',
  62. fixed = {-.45, -.5, -.4, .45, .4, .5},
  63. },
  64. collision_box = {
  65. type = 'fixed',
  66. fixed = {-.45, -.5, -.4, .45, .4, .5},
  67. },
  68. groups = {oddly_breakable_by_hand = 2, choppy=3, stainable=1},
  69. on_construct = function(pos)
  70. local meta = minetest.get_meta(pos)
  71. meta:set_string('formspec', furniture.storage_32_form(pos, ''))
  72. local inv = meta:get_inventory()
  73. inv:set_size('main', 32)
  74. end,
  75. can_dig = function(pos,player)
  76. local meta = minetest.get_meta(pos)
  77. local inv = meta:get_inventory()
  78. return inv:is_empty('main')
  79. end,
  80. on_receive_fields = function(pos, formname, fields, sender)
  81. local player_name = sender:get_player_name()
  82. if minetest.is_protected(pos, player_name) and not minetest.check_player_privs(sender, 'protection_bypass') then
  83. return
  84. end
  85. local meta = minetest.get_meta(pos)
  86. if fields ['save'] then
  87. meta:set_string('infotext', fields.description)
  88. meta:set_string('formspec', furniture.storage_32_form(pos, fields.description))
  89. elseif fields ['sort'] then
  90. furniture.sort_inventory(meta:get_inventory())
  91. end
  92. end,
  93. allow_metadata_inventory_put = furniture.inv_take_put,
  94. allow_metadata_inventory_take = furniture.inv_take_put,
  95. allow_metadata_inventory_move = furniture.inv_manipulate,
  96. on_metadata_inventory_put = furniture.inv_put,
  97. on_metadata_inventory_take = furniture.inv_take,
  98. })
  99. minetest.register_node('furniture:chest_large', {
  100. _doc_items_crafting = 'This is crafted in the Woodworking Station.',
  101. description = 'Large Chest',
  102. drawtype = 'mesh',
  103. mesh = 'furniture_chest_large.obj',
  104. tiles = {'furniture_chest_large.png'},
  105. overlay_tiles = {{name='furniture_chest_large_overlay.png', color='white'}},
  106. use_texture_alpha = 'opaque',
  107. paramtype = 'light',
  108. paramtype2 = 'colorfacedir',
  109. palette = 'furniture_stain_palette.png',
  110. selection_box = {
  111. type = 'fixed',
  112. fixed = {-.5, -.5, -.4, 1.5, .3, .5},
  113. },
  114. collision_box = {
  115. type = 'fixed',
  116. fixed = {-.5, -.5, -.4, 1.5, .3, .5},
  117. },
  118. groups = {oddly_breakable_by_hand = 2, choppy=3, stainable=1},
  119. after_place_node = function(pos, placer, itemstack)
  120. if not epic.space_to_side(pos) then
  121. minetest.remove_node(pos)
  122. return itemstack
  123. end
  124. end,
  125. on_construct = function(pos)
  126. local meta = minetest.get_meta(pos)
  127. meta:set_string('formspec', furniture.storage_60_form(pos, ''))
  128. local inv = meta:get_inventory()
  129. inv:set_size('main', 60)
  130. end,
  131. after_dig_node = function(pos, oldnode, oldmetadata, digger)
  132. epic.remove_side_node(pos, oldnode)
  133. end,
  134. can_dig = function(pos,player)
  135. local meta = minetest.get_meta(pos)
  136. local inv = meta:get_inventory()
  137. return inv:is_empty('main')
  138. end,
  139. on_receive_fields = function(pos, formname, fields, sender)
  140. local player_name = sender:get_player_name()
  141. if minetest.is_protected(pos, player_name) and not minetest.check_player_privs(sender, 'protection_bypass') then
  142. return
  143. end
  144. local meta = minetest.get_meta(pos)
  145. if fields ['save'] then
  146. meta:set_string('infotext', fields.description)
  147. meta:set_string('formspec', furniture.storage_60_form(pos, fields.description))
  148. elseif fields ['sort'] then
  149. furniture.sort_inventory(meta:get_inventory())
  150. end
  151. end,
  152. on_rotate = function(pos, node)
  153. return false
  154. end,
  155. allow_metadata_inventory_put = furniture.inv_take_put,
  156. allow_metadata_inventory_take = furniture.inv_take_put,
  157. allow_metadata_inventory_move = furniture.inv_manipulate,
  158. on_metadata_inventory_put = furniture.inv_put,
  159. on_metadata_inventory_take = furniture.inv_take,
  160. })
  161. minetest.register_node('furniture:cabinet_wall', {
  162. _doc_items_crafting = 'This is crafted in the Woodworking Station.',
  163. description = 'Wall Mounted Cabinet',
  164. drawtype = 'mesh',
  165. mesh = 'furniture_cabinet_wall.obj',
  166. tiles = {'furniture_cabinet_wall.png'},
  167. paramtype = 'light',
  168. paramtype2 = 'colorfacedir',
  169. palette = 'furniture_stain_palette.png',
  170. selection_box = {
  171. type = 'fixed',
  172. fixed = {-.5, -.5, -.3, .5, .5, .5},
  173. },
  174. collision_box = {
  175. type = 'fixed',
  176. fixed = {-.5, -.5, -.3, .5, .5, .5},
  177. },
  178. groups = {oddly_breakable_by_hand = 2, choppy=3, stainable=1},
  179. on_construct = function(pos)
  180. local meta = minetest.get_meta(pos)
  181. meta:set_string('formspec', furniture.storage_24_form(pos, ''))
  182. local inv = meta:get_inventory()
  183. inv:set_size('main', 24)
  184. end,
  185. can_dig = function(pos,player)
  186. local meta = minetest.get_meta(pos)
  187. local inv = meta:get_inventory()
  188. return inv:is_empty('main')
  189. end,
  190. on_receive_fields = function(pos, formname, fields, sender)
  191. local player_name = sender:get_player_name()
  192. if minetest.is_protected(pos, player_name) and not minetest.check_player_privs(sender, 'protection_bypass') then
  193. return
  194. end
  195. local meta = minetest.get_meta(pos)
  196. if fields ['save'] then
  197. meta:set_string('infotext', fields.description)
  198. meta:set_string('formspec', furniture.storage_24_form(pos, fields.description))
  199. elseif fields ['sort'] then
  200. furniture.sort_inventory(meta:get_inventory())
  201. end
  202. end,
  203. allow_metadata_inventory_put = furniture.inv_take_put,
  204. allow_metadata_inventory_take = furniture.inv_take_put,
  205. allow_metadata_inventory_move = furniture.inv_manipulate,
  206. on_metadata_inventory_put = furniture.inv_put,
  207. on_metadata_inventory_take = furniture.inv_take,
  208. })
  209. minetest.register_node('furniture:cabinet_counter', {
  210. _doc_items_crafting = 'This is crafted in the Woodworking Station.',
  211. description = 'Cabinet with Countertop',
  212. drawtype = 'mesh',
  213. mesh = 'furniture_cabinet_counter.obj',
  214. tiles = {'furniture_cabinet_counter.png'},
  215. paramtype = 'light',
  216. paramtype2 = 'colorfacedir',
  217. palette = 'furniture_stain_palette.png',
  218. selection_box = {
  219. type = 'fixed',
  220. fixed = {-.5, -.5, -.5, .5, .5, .5},
  221. },
  222. collision_box = {
  223. type = 'fixed',
  224. fixed = {-.5, -.5, -.5, .5, .5, .5},
  225. },
  226. groups = {oddly_breakable_by_hand = 2, choppy=3, stainable=1},
  227. on_construct = function(pos)
  228. local meta = minetest.get_meta(pos)
  229. meta:set_string('formspec', furniture.storage_24_form(pos, ''))
  230. local inv = meta:get_inventory()
  231. inv:set_size('main', 24)
  232. end,
  233. can_dig = function(pos,player)
  234. local meta = minetest.get_meta(pos)
  235. local inv = meta:get_inventory()
  236. return inv:is_empty('main')
  237. end,
  238. on_receive_fields = function(pos, formname, fields, sender)
  239. local player_name = sender:get_player_name()
  240. if minetest.is_protected(pos, player_name) and not minetest.check_player_privs(sender, 'protection_bypass') then
  241. return
  242. end
  243. local meta = minetest.get_meta(pos)
  244. if fields ['save'] then
  245. meta:set_string('infotext', fields.description)
  246. meta:set_string('formspec', furniture.storage_24_form(pos, fields.description))
  247. elseif fields ['sort'] then
  248. furniture.sort_inventory(meta:get_inventory())
  249. end
  250. end,
  251. allow_metadata_inventory_put = furniture.inv_take_put,
  252. allow_metadata_inventory_take = furniture.inv_take_put,
  253. allow_metadata_inventory_move = furniture.inv_manipulate,
  254. on_metadata_inventory_put = furniture.inv_put,
  255. on_metadata_inventory_take = furniture.inv_take,
  256. })
  257. minetest.register_node('furniture:cabinet_counter_corner_inside', {
  258. description = 'Cabinet with Countertop',
  259. drawtype = 'mesh',
  260. mesh = 'furniture_cabinet_counter_corner_inside.obj',
  261. tiles = {'furniture_cabinet_counter.png'},
  262. paramtype = 'light',
  263. paramtype2 = 'colorfacedir',
  264. palette = 'furniture_stain_palette.png',
  265. selection_box = {
  266. type = 'fixed',
  267. fixed = {-.5, -.5, -.5, .5, .5, .5},
  268. },
  269. collision_box = {
  270. type = 'fixed',
  271. fixed = {-.5, -.5, -.5, .5, .5, .5},
  272. },
  273. groups = {oddly_breakable_by_hand = 2, choppy=3, stainable=1},
  274. on_construct = function(pos)
  275. local meta = minetest.get_meta(pos)
  276. meta:set_string('formspec', furniture.storage_24_form(pos, ''))
  277. local inv = meta:get_inventory()
  278. inv:set_size('main', 24)
  279. end,
  280. can_dig = function(pos,player)
  281. local meta = minetest.get_meta(pos)
  282. local inv = meta:get_inventory()
  283. return inv:is_empty('main')
  284. end,
  285. on_receive_fields = function(pos, formname, fields, sender)
  286. local player_name = sender:get_player_name()
  287. if minetest.is_protected(pos, player_name) and not minetest.check_player_privs(sender, 'protection_bypass') then
  288. return
  289. end
  290. local meta = minetest.get_meta(pos)
  291. if fields ['save'] then
  292. meta:set_string('infotext', fields.description)
  293. meta:set_string('formspec', furniture.storage_24_form(pos, fields.description))
  294. elseif fields ['sort'] then
  295. furniture.sort_inventory(meta:get_inventory())
  296. end
  297. end,
  298. allow_metadata_inventory_put = furniture.inv_take_put,
  299. allow_metadata_inventory_take = furniture.inv_take_put,
  300. allow_metadata_inventory_move = furniture.inv_manipulate,
  301. on_metadata_inventory_put = furniture.inv_put,
  302. on_metadata_inventory_take = furniture.inv_take,
  303. })
  304. minetest.register_node('furniture:cabinet_counter_corner_outside', {
  305. description = 'Cabinet with Countertop',
  306. drawtype = 'mesh',
  307. mesh = 'furniture_cabinet_counter_corner_outside.obj',
  308. tiles = {'furniture_cabinet_counter.png'},
  309. paramtype = 'light',
  310. paramtype2 = 'colorfacedir',
  311. palette = 'furniture_stain_palette.png',
  312. selection_box = {
  313. type = 'fixed',
  314. fixed = {-.5, -.5, -.5, .5, .5, .5},
  315. },
  316. collision_box = {
  317. type = 'fixed',
  318. fixed = {-.5, -.5, -.5, .5, .5, .5},
  319. },
  320. groups = {oddly_breakable_by_hand = 2, choppy=3, stainable=1},
  321. on_construct = function(pos)
  322. local meta = minetest.get_meta(pos)
  323. meta:set_string('formspec', furniture.storage_24_form(pos, ''))
  324. local inv = meta:get_inventory()
  325. inv:set_size('main', 24)
  326. end,
  327. can_dig = function(pos,player)
  328. local meta = minetest.get_meta(pos)
  329. local inv = meta:get_inventory()
  330. return inv:is_empty('main')
  331. end,
  332. on_receive_fields = function(pos, formname, fields, sender)
  333. local player_name = sender:get_player_name()
  334. if minetest.is_protected(pos, player_name) and not minetest.check_player_privs(sender, 'protection_bypass') then
  335. return
  336. end
  337. local meta = minetest.get_meta(pos)
  338. if fields ['save'] then
  339. meta:set_string('infotext', fields.description)
  340. meta:set_string('formspec', furniture.storage_24_form(pos, fields.description))
  341. elseif fields ['sort'] then
  342. furniture.sort_inventory(meta:get_inventory())
  343. end
  344. end,
  345. allow_metadata_inventory_put = furniture.inv_take_put,
  346. allow_metadata_inventory_take = furniture.inv_take_put,
  347. allow_metadata_inventory_move = furniture.inv_manipulate,
  348. on_metadata_inventory_put = furniture.inv_put,
  349. on_metadata_inventory_take = furniture.inv_take,
  350. })
  351. local bookshelf_formspec =
  352. "size[8,7;]" ..
  353. "list[context;books;0,0.3;8,2;]" ..
  354. "list[current_player;main;0,2.85;8,1;]" ..
  355. "list[current_player;main;0,4.08;8,3;8]" ..
  356. "listring[context;books]" ..
  357. "listring[current_player;main]" ..
  358. default.get_hotbar_bg(0,2.85)
  359. local function update_bookshelf(pos)
  360. local meta = minetest.get_meta(pos)
  361. local inv = meta:get_inventory()
  362. local invlist = inv:get_list("books")
  363. local formspec = bookshelf_formspec
  364. -- Inventory slots overlay
  365. local bx, by = 0, 0.3
  366. local n_written, n_empty = 0, 0
  367. for i = 1, 16 do
  368. if i == 9 then
  369. bx = 0
  370. by = by + 1
  371. end
  372. local stack = invlist[i]
  373. if stack:is_empty() then
  374. formspec = formspec ..
  375. "image[" .. bx .. "," .. by .. ";1,1;default_bookshelf_slot.png]"
  376. else
  377. local metatable = stack:get_meta():to_table() or {}
  378. if metatable.fields and metatable.fields.text then
  379. n_written = n_written + stack:get_count()
  380. else
  381. n_empty = n_empty + stack:get_count()
  382. end
  383. end
  384. bx = bx + 1
  385. end
  386. meta:set_string("formspec", formspec)
  387. if n_written + n_empty == 0 then
  388. meta:set_string("infotext", "Empty Locked Bookshelf")
  389. else
  390. meta:set_string("infotext", "Locked Bookshelf ("..n_written.." written, "..n_empty.." empty books)")
  391. end
  392. end
  393. minetest.register_node("furniture:bookshelf_locked", {
  394. description = 'Locked Bookshelf',
  395. tiles = {"default_wood.png", "default_wood.png", "default_wood.png",
  396. "default_wood.png", "default_bookshelf.png", "default_bookshelf.png"},
  397. paramtype2 = "facedir",
  398. is_ground_content = false,
  399. groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3},
  400. sounds = default.node_sound_wood_defaults(),
  401. on_construct = function(pos)
  402. local meta = minetest.get_meta(pos)
  403. local inv = meta:get_inventory()
  404. inv:set_size("books", 8 * 2)
  405. update_bookshelf(pos)
  406. end,
  407. can_dig = function(pos,player)
  408. local inv = minetest.get_meta(pos):get_inventory()
  409. return inv:is_empty("books")
  410. end,
  411. allow_metadata_inventory_put = function(pos, listname, index, stack, player)
  412. local player_name = player:get_player_name()
  413. if minetest.is_protected(pos, player_name) and not minetest.check_player_privs(player, 'protection_bypass') then
  414. return 0
  415. else
  416. if minetest.get_item_group(stack:get_name(), "book") ~= 0 then
  417. return stack:get_count()
  418. else
  419. return 0
  420. end
  421. end
  422. end,
  423. allow_metadata_inventory_take = furniture.inv_take_put,
  424. allow_metadata_inventory_move = furniture.inv_manipulate,
  425. on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
  426. minetest.log("action", player:get_player_name() ..
  427. " moves stuff in bookshelf at " .. minetest.pos_to_string(pos))
  428. update_bookshelf(pos)
  429. end,
  430. on_metadata_inventory_put = function(pos, listname, index, stack, player)
  431. minetest.log("action", player:get_player_name() ..
  432. " puts stuff to bookshelf at " .. minetest.pos_to_string(pos))
  433. update_bookshelf(pos)
  434. end,
  435. on_metadata_inventory_take = function(pos, listname, index, stack, player)
  436. minetest.log("action", player:get_player_name() ..
  437. " takes stuff from bookshelf at " .. minetest.pos_to_string(pos))
  438. update_bookshelf(pos)
  439. end,
  440. on_blast = function(pos)
  441. local drops = {}
  442. default.get_inventory_drops(pos, "books", drops)
  443. drops[#drops+1] = "furniture:bookshelf_locked"
  444. minetest.remove_node(pos)
  445. return drops
  446. end,
  447. })
  448. local vessels_shelf_formspec =
  449. "size[8,7;]" ..
  450. "list[context;vessels;0,0.3;8,2;]" ..
  451. "list[current_player;main;0,2.85;8,1;]" ..
  452. "list[current_player;main;0,4.08;8,3;8]" ..
  453. "listring[context;vessels]" ..
  454. "listring[current_player;main]" ..
  455. default.get_hotbar_bg(0, 2.85)
  456. local function update_vessels_shelf(pos)
  457. local meta = minetest.get_meta(pos)
  458. local inv = meta:get_inventory()
  459. local invlist = inv:get_list("vessels")
  460. local formspec = vessels_shelf_formspec
  461. -- Inventory slots overlay
  462. local vx, vy = 0, 0.3
  463. local n_items = 0
  464. for i = 1, 16 do
  465. if i == 9 then
  466. vx = 0
  467. vy = vy + 1
  468. end
  469. if not invlist or invlist[i]:is_empty() then
  470. formspec = formspec ..
  471. "image[" .. vx .. "," .. vy .. ";1,1;vessels_shelf_slot.png]"
  472. else
  473. local stack = invlist[i]
  474. if not stack:is_empty() then
  475. n_items = n_items + stack:get_count()
  476. end
  477. end
  478. vx = vx + 1
  479. end
  480. meta:set_string("formspec", formspec)
  481. if n_items == 0 then
  482. meta:set_string("infotext", "Empty Locked Vessels Shelf")
  483. else
  484. meta:set_string("infotext", "Locked Vessels Shelf ("..n_items.." items)")
  485. end
  486. end
  487. minetest.register_node("furniture:shelf_vessel_locked", {
  488. description = "Locked Vessels Shelf",
  489. tiles = {"default_wood.png", "default_wood.png", "default_wood.png",
  490. "default_wood.png", "vessels_shelf.png", "vessels_shelf.png"},
  491. paramtype2 = "facedir",
  492. is_ground_content = false,
  493. groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3},
  494. sounds = default.node_sound_wood_defaults(),
  495. on_construct = function(pos)
  496. local meta = minetest.get_meta(pos)
  497. update_vessels_shelf(pos)
  498. local inv = meta:get_inventory()
  499. inv:set_size("vessels", 8 * 2)
  500. end,
  501. can_dig = function(pos,player)
  502. local inv = minetest.get_meta(pos):get_inventory()
  503. return inv:is_empty("vessels")
  504. end,
  505. allow_metadata_inventory_take = furniture.inv_take_put,
  506. allow_metadata_inventory_move = furniture.inv_manipulate,
  507. allow_metadata_inventory_put = function(pos, listname, index, stack, player)
  508. local player_name = player:get_player_name()
  509. if minetest.is_protected(pos, player_name) and not minetest.check_player_privs(player, 'protection_bypass') then
  510. return 0
  511. else
  512. if minetest.get_item_group(stack:get_name(), "vessel") ~= 0 then
  513. return stack:get_count()
  514. else
  515. return 0
  516. end
  517. end
  518. end,
  519. on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
  520. minetest.log("action", player:get_player_name() ..
  521. " moves stuff in vessels shelf at ".. minetest.pos_to_string(pos))
  522. update_vessels_shelf(pos)
  523. end,
  524. on_metadata_inventory_put = function(pos, listname, index, stack, player)
  525. minetest.log("action", player:get_player_name() ..
  526. " moves stuff to vessels shelf at ".. minetest.pos_to_string(pos))
  527. update_vessels_shelf(pos)
  528. end,
  529. on_metadata_inventory_take = function(pos, listname, index, stack, player)
  530. minetest.log("action", player:get_player_name() ..
  531. " takes stuff from vessels shelf at ".. minetest.pos_to_string(pos))
  532. update_vessels_shelf(pos)
  533. end,
  534. on_blast = function(pos)
  535. local drops = {}
  536. default.get_inventory_drops(pos, "vessels", drops)
  537. drops[#drops + 1] = "vessels:shelf"
  538. minetest.remove_node(pos)
  539. return drops
  540. end,
  541. })
  542. minetest.register_node("furniture:multishelf_locked", {
  543. description = "Locked Multishelf",
  544. tiles = {
  545. "default_wood.png", "default_wood.png", "default_wood.png",
  546. "default_wood.png", "default_wood.png^xdecor_multishelf.png"},
  547. paramtype2 = "facedir",
  548. is_ground_content = false,
  549. groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3},
  550. sounds = default.node_sound_wood_defaults(),
  551. on_construct = function(pos)
  552. local meta = minetest.get_meta(pos)
  553. update_vessels_shelf(pos)
  554. local inv = meta:get_inventory()
  555. inv:set_size("vessels", 8 * 2)
  556. end,
  557. can_dig = function(pos,player)
  558. local inv = minetest.get_meta(pos):get_inventory()
  559. return inv:is_empty("vessels")
  560. end,
  561. allow_metadata_inventory_take = furniture.inv_take_put,
  562. allow_metadata_inventory_move = furniture.inv_manipulate,
  563. allow_metadata_inventory_put = function(pos, listname, index, stack, player)
  564. local player_name = player:get_player_name()
  565. if minetest.is_protected(pos, player_name) and not minetest.check_player_privs(player, 'protection_bypass') then
  566. return 0
  567. else return stack:get_count()
  568. end
  569. end,
  570. on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
  571. minetest.log("action", player:get_player_name() ..
  572. " moves stuff in multi shelf at ".. minetest.pos_to_string(pos))
  573. end,
  574. on_metadata_inventory_put = function(pos, listname, index, stack, player)
  575. minetest.log("action", player:get_player_name() ..
  576. " moves stuff to multi shelf at ".. minetest.pos_to_string(pos))
  577. end,
  578. on_metadata_inventory_take = function(pos, listname, index, stack, player)
  579. minetest.log("action", player:get_player_name() ..
  580. " takes stuff from multi shelf at ".. minetest.pos_to_string(pos))
  581. end,
  582. on_blast = function(pos)
  583. local drops = {}
  584. default.get_inventory_drops(pos, "vessels", drops)
  585. drops[#drops + 1] = "vessels:shelf"
  586. minetest.remove_node(pos)
  587. return drops
  588. end,
  589. })