Differences From
Artifact [087023acf7]:
358 358 end
359 359 return i, false
360 360 end
361 361 else
362 362 return function(i) return i, false end
363 363 end
364 364 end;
365 +
366 + autopreserve = function(id, tbl)
367 + tbl.drop = tbl.drop or {
368 + max_items = 1;
369 + items = {
370 + { items = {id} };
371 + };
372 + }
373 + local next_apn = tbl.after_place_node
374 + tbl.after_place_node = function(...) local pos, who, stack = ...
375 + minetest.get_meta(pos):from_table(stack:get_meta():to_table())
376 + if next_apn then return next_apn(...) end
377 + end
378 + local next_pm = tbl.preserve_metadata
379 + tbl.preserve_metadata = function(...) local pos, node, meta, drops = ...
380 + drops[1]:get_meta():from_table({fields = meta})
381 + if next_pm then return next_pm(...) end
382 + end
383 + return tbl
384 + end;
385 + reg_autopreserve = function(id, tbl)
386 + minetest.register_node(id, sorcery.lib.node.autopreserve(id, tbl))
387 + end;
365 388 }