@@ -7,6 +7,8 @@ local S = digtron.S
77
88local node_inventory_table = {type = " node" } -- a reusable parameter for get_inventory calls, set the pos parameter before using.
99
10+ local has_wrench_mod = minetest .get_modpath (" wrench" )
11+
1012local displace_due_to_help_button = 1.0
1113if minetest .get_modpath (" doc" ) then
1214 displace_due_to_help_button = 0.0
@@ -70,6 +72,15 @@ local builder_on_rightclick = function(pos, _, clicker, itemstack, pointed_thing
7072 builder_formspec (pos , meta ))
7173end
7274
75+ local function sanitize_item (item )
76+ -- check if the item can be "wrenched"
77+ if has_wrench_mod and wrench .registered_nodes [item :get_name ()] then
78+ -- item can be "wrenched" (contains the inventory serialized in the "data" field)
79+ -- remove the serialized data on the placed node
80+ item :get_meta ():set_string (" data" , " " )
81+ end
82+ end
83+
7384minetest .register_on_player_receive_fields (function (sender , formname , fields )
7485
7586 if formname :sub (1 , 15 ) ~= " digtron:builder" then
@@ -277,7 +288,10 @@ minetest.register_node("digtron:builder", {
277288
278289 node_inventory_table .pos = pos
279290 local inv = minetest .get_inventory (node_inventory_table )
280- inv :set_stack (listname , index , stack :take_item (1 ))
291+ local item = stack :take_item (1 )
292+ sanitize_item (item )
293+
294+ inv :set_stack (listname , index , item )
281295
282296 -- If we're adding a wallmounted item and the build facing is greater than 5, reset it to 0
283297 local meta = minetest .get_meta (pos )
@@ -524,7 +538,10 @@ minetest.register_node("digtron:master_builder", {
524538
525539 node_inventory_table .pos = pos
526540 local inv = minetest .get_inventory (node_inventory_table )
527- inv :set_stack (listname , index , stack :take_item (1 ))
541+ local item = stack :take_item (1 )
542+ sanitize_item (item )
543+
544+ inv :set_stack (listname , index , item )
528545
529546 -- If we're adding a wallmounted item and the build facing is greater than 5, reset it to 0
530547 local meta = minetest .get_meta (pos )
0 commit comments