Skip to content

Commit 23ba999

Browse files
fix wrench duplication
1 parent 619b7db commit 23ba999

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

.luacheckrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ read_globals = {
2121
"doc",
2222
"intllib",
2323
"fakelib",
24+
"wrench"
2425
}
2526

2627
files = {

util_item_place_node.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ digtron.facedir_to_dir_map = {
2828
1, 4, 3, 2,
2929
}
3030

31+
local has_wrench_mod = minetest.get_modpath("wrench")
32+
3133
local function has_prefix(str, prefix)
3234
return str:sub(1, string.len(prefix)) == prefix
3335
end
@@ -145,6 +147,13 @@ digtron.item_place_node = function(itemstack, placer, place_to, param2)
145147
-- Add node and update
146148
minetest.add_node(place_to, newnode)
147149

150+
-- check if the item can be "wrenched"
151+
if has_wrench_mod and wrench.registered_nodes[itemstack:get_name()] then
152+
-- item can be "wrenched" (contains the inventory serialized in the "data" field)
153+
-- remove the serialized data on the placed node
154+
itemstack:get_meta():set_string("data", "")
155+
end
156+
148157
local take_item = true
149158

150159
-- Run callback, using genuine player for per-node definition.

0 commit comments

Comments
 (0)