diff --git a/bag.lua b/bag.lua index ee8f773..4b53e31 100644 --- a/bag.lua +++ b/bag.lua @@ -80,8 +80,8 @@ local function on_place(itemstack, player, pointed_thing) end end - if selected_item then - local pos = edit.pointed_thing_to_pos(pointed_thing) + local pos = edit.pointed_thing_to_pos(pointed_thing) + if selected_item and pos then edit.place_item_like_player(player, {name = selected_item}, pos) end end diff --git a/replace.lua b/replace.lua index 5d99822..a541b2a 100644 --- a/replace.lua +++ b/replace.lua @@ -226,11 +226,12 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) local pos = vector.new(x, y, z) local node = minetest.get_node(pos) local old_name = node.name - node.name = item_string if replace_source_nodes[old_name] then if is_node then + node.name = name minetest.swap_node(pos, node) else + node.name = item_string edit.place_item_like_player(player, node, pos) end end