summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Arndt <jayarn27182@windstream.net>2015-03-07 05:41:31 -0600
committerShadowNinja <shadowninja@minetest.net>2015-03-07 21:44:42 -0500
commitc8cbd261ee75b093d5ccb0d00e90e28dabe0914e (patch)
tree61a2286ed5d2d3525a69678fd8da5a2bfead7f04
parentc6464d3ebe38de5a73d5f41a36bf128db7104d61 (diff)
Drop upgrade items in the after_dig_node handler instead of can_dig
This fixes an item duplication bug triggered by using a screwdriver on an upgraded machine
-rw-r--r--technic/machines/MV/tool_workshop.lua2
-rw-r--r--technic/machines/register/battery_box.lua2
-rw-r--r--technic/machines/register/common.lua27
-rw-r--r--technic/machines/register/generator.lua2
-rw-r--r--technic/machines/register/machine_base.lua2
5 files changed, 25 insertions, 10 deletions
diff --git a/technic/machines/MV/tool_workshop.lua b/technic/machines/MV/tool_workshop.lua
index 8988f93..f94a88a 100644
--- a/technic/machines/MV/tool_workshop.lua
+++ b/technic/machines/MV/tool_workshop.lua
@@ -102,7 +102,7 @@ minetest.register_node("technic:tool_workshop", {
},
technic_run = run,
after_place_node = pipeworks.after_place,
- after_dig_node = pipeworks.after_dig
+ after_dig_node = technic.machine_after_dig_node
})
technic.register_machine("MV", "technic:tool_workshop", technic.receiver)
diff --git a/technic/machines/register/battery_box.lua b/technic/machines/register/battery_box.lua
index 6a10fb5..412f5ba 100644
--- a/technic/machines/register/battery_box.lua
+++ b/technic/machines/register/battery_box.lua
@@ -196,7 +196,7 @@ function technic.register_battery_box(data)
allow_metadata_inventory_move = technic.machine_inventory_move,
technic_run = run,
after_place_node = tube and pipeworks.after_place,
- after_dig_node = tube and pipeworks.after_dig
+ after_dig_node = technic.machine_after_dig_node
})
end
diff --git a/technic/machines/register/common.lua b/technic/machines/register/common.lua
index 0168c40..ce0eee6 100644
--- a/technic/machines/register/common.lua
+++ b/technic/machines/register/common.lua
@@ -147,14 +147,29 @@ function technic.machine_can_dig(pos, player)
S("Machine cannot be removed because it is not empty"))
end
return false
- else
- if not inv:is_empty("upgrade1") then
- minetest.item_drop(inv:get_stack("upgrade1", 1), "", pos)
+ end
+
+ return true
+end
+
+function technic.machine_after_dig_node(pos, oldnode, oldmetadata, player)
+ if oldmetadata.inventory then
+ if oldmetadata.inventory.upgrade1 and oldmetadata.inventory.upgrade1[1] then
+ local stack = ItemStack(oldmetadata.inventory.upgrade1[1])
+ if not stack:is_empty() then
+ minetest.item_drop(stack, "", pos)
+ end
end
- if not inv:is_empty("upgrade2") then
- minetest.item_drop(inv:get_stack("upgrade2", 1), "", pos)
+ if oldmetadata.inventory.upgrade2 and oldmetadata.inventory.upgrade2[1] then
+ local stack = ItemStack(oldmetadata.inventory.upgrade2[1])
+ if not stack:is_empty() then
+ minetest.item_drop(stack, "", pos)
+ end
end
- return true
+ end
+
+ if minetest.registered_nodes[oldnode.name].tube then
+ pipeworks.after_dig(pos, oldnode, oldmetadata, player)
end
end
diff --git a/technic/machines/register/generator.lua b/technic/machines/register/generator.lua
index 719dc93..aa367ca 100644
--- a/technic/machines/register/generator.lua
+++ b/technic/machines/register/generator.lua
@@ -110,7 +110,7 @@ function technic.register_generator(data)
allow_metadata_inventory_move = technic.machine_inventory_move,
technic_run = run,
after_place_node = tube and pipeworks.after_place,
- after_dig_node = tube and pipeworks.after_dig
+ after_dig_node = technic.machine_after_dig_node
})
minetest.register_node("technic:"..ltier.."_generator_active", {
diff --git a/technic/machines/register/machine_base.lua b/technic/machines/register/machine_base.lua
index 9cdcce9..0f47c22 100644
--- a/technic/machines/register/machine_base.lua
+++ b/technic/machines/register/machine_base.lua
@@ -154,7 +154,7 @@ function technic.register_base_machine(data)
allow_metadata_inventory_move = technic.machine_inventory_move,
technic_run = run,
after_place_node = tube and pipeworks.after_place,
- after_dig_node = tube and pipeworks.after_dig
+ after_dig_node = technic.machine_after_dig_node
})
minetest.register_node("technic:"..ltier.."_"..machine_name.."_active",{