Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ read_globals = {
"doc",
"intllib",
"fakelib",
"wrench"
}

files = {
Expand Down
21 changes: 19 additions & 2 deletions nodes/node_builders.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ local S = digtron.S

local node_inventory_table = {type="node"} -- a reusable parameter for get_inventory calls, set the pos parameter before using.

local has_wrench_mod = minetest.get_modpath("wrench")

local displace_due_to_help_button = 1.0
if minetest.get_modpath("doc") then
displace_due_to_help_button = 0.0
Expand Down Expand Up @@ -70,6 +72,15 @@ local builder_on_rightclick = function(pos, _, clicker, itemstack, pointed_thing
builder_formspec(pos, meta))
end

local function sanitize_item(item)
-- check if the item can be "wrenched"
if has_wrench_mod and wrench.registered_nodes[item:get_name()] then
-- item can be "wrenched" (contains the inventory serialized in the "data" field)
-- remove the serialized data on the placed node
item:get_meta():set_string("data", "")
end
end

minetest.register_on_player_receive_fields(function(sender, formname, fields)

if formname:sub(1, 15) ~= "digtron:builder" then
Expand Down Expand Up @@ -277,7 +288,10 @@ minetest.register_node("digtron:builder", {

node_inventory_table.pos = pos
local inv = minetest.get_inventory(node_inventory_table)
inv:set_stack(listname, index, stack:take_item(1))
local item = stack:take_item(1)
sanitize_item(item)

inv:set_stack(listname, index, item)

-- If we're adding a wallmounted item and the build facing is greater than 5, reset it to 0
local meta = minetest.get_meta(pos)
Expand Down Expand Up @@ -524,7 +538,10 @@ minetest.register_node("digtron:master_builder", {

node_inventory_table.pos = pos
local inv = minetest.get_inventory(node_inventory_table)
inv:set_stack(listname, index, stack:take_item(1))
local item = stack:take_item(1)
sanitize_item(item)

inv:set_stack(listname, index, item)

-- If we're adding a wallmounted item and the build facing is greater than 5, reset it to 0
local meta = minetest.get_meta(pos)
Expand Down