summaryrefslogtreecommitdiff
path: root/nodes/node_crate.lua
diff options
context:
space:
mode:
Diffstat (limited to 'nodes/node_crate.lua')
-rw-r--r--nodes/node_crate.lua20
1 files changed, 19 insertions, 1 deletions
diff --git a/nodes/node_crate.lua b/nodes/node_crate.lua
index 7e30207..101d7bb 100644
--- a/nodes/node_crate.lua
+++ b/nodes/node_crate.lua
@@ -2,6 +2,8 @@
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
+local modpath_awards = minetest.get_modpath("awards")
+
minetest.register_node("digtron:empty_crate", {
description = S("Digtron Crate (Empty)"),
_doc_items_longdesc = digtron.doc.empty_crate_longdesc,
@@ -30,7 +32,23 @@ minetest.register_node("digtron:empty_crate", {
-- destroy everything. Note that this includes the empty crate, which will be bundled up with the layout.
for _, node_image in pairs(layout.all) do
- minetest.remove_node(node_image.pos)
+ local old_pos = node_image.pos
+ local old_node = node_image.node
+ minetest.remove_node(old_pos)
+
+ if modpath_awards then
+ -- We're about to tell the awards mod that we're digging a node, but we
+ -- don't want it to count toward any actual awards. Pre-decrement.
+ local data = awards.players[clicker:get_player_name()]
+ awards.increment_item_counter(data, "count", old_node.name, -1)
+ end
+
+ for _, callback in ipairs(minetest.registered_on_dignodes) do
+ -- Copy pos and node because callback can modify them
+ local pos_copy = {x=old_pos.x, y=old_pos.y, z=old_pos.z}
+ local oldnode_copy = {name=old_node.name, param1=old_node.param1, param2=old_node.param2}
+ callback(pos_copy, oldnode_copy, clicker)
+ end
end
-- Create the loaded crate node