Digtron Battery: Fix duplication bug
This is done by using `preserve_metadata` instead of a custom `after_dig_node` callback.
This commit is contained in:
parent
c2d0746eb9
commit
d4a65cfb63
@ -233,6 +233,7 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode, validState
|
|||||||
on_rightclick = tNode.on_rightclick,
|
on_rightclick = tNode.on_rightclick,
|
||||||
after_place_node = after_place_node,
|
after_place_node = after_place_node,
|
||||||
after_dig_node = after_dig_node,
|
after_dig_node = after_dig_node,
|
||||||
|
preserve_metadata = tNode.preserve_metadata,
|
||||||
tubelib2_on_update2 = tubelib2_on_update2,
|
tubelib2_on_update2 = tubelib2_on_update2,
|
||||||
allow_metadata_inventory_put = tNode.allow_metadata_inventory_put,
|
allow_metadata_inventory_put = tNode.allow_metadata_inventory_put,
|
||||||
allow_metadata_inventory_move = tNode.allow_metadata_inventory_move,
|
allow_metadata_inventory_move = tNode.allow_metadata_inventory_move,
|
||||||
|
@ -140,27 +140,21 @@ techage.register_consumer("digtron_battery", S("Digtron Battery"), { act = tiles
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
preserve_metadata = function(pos, oldnode, oldmetadata, drops)
|
||||||
local node = ItemStack(oldnode.name)
|
metadata = M(pos):to_table()
|
||||||
if oldmetadata.inventory then
|
if metadata.inventory then
|
||||||
local total = count_coal(oldmetadata)
|
local total = count_coal(metadata)
|
||||||
local meta = node:get_meta()
|
local meta = drops[1]:get_meta()
|
||||||
meta:set_int("coal", total)
|
meta:set_int("coal", total)
|
||||||
local text = S("Digtron Battery").." ("..math.floor(total/TOTAL_MAX * 100).." %)"
|
local text = S("Digtron Battery").." ("..math.floor(total/TOTAL_MAX * 100).." %)"
|
||||||
meta:set_string("description", text)
|
meta:set_string("description", text)
|
||||||
end
|
end
|
||||||
local inv = minetest.get_inventory({type="player", name=digger:get_player_name()})
|
|
||||||
local left_over = inv:add_item("main", node)
|
|
||||||
if left_over:get_count() > 0 then
|
|
||||||
minetest.add_item(pos, node)
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
on_rightclick = function(pos, node, clicker)
|
on_rightclick = function(pos, node, clicker)
|
||||||
techage.set_activeformspec(pos, clicker)
|
techage.set_activeformspec(pos, clicker)
|
||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
M(pos):set_string("formspec", formspec(CRD(pos).State, pos, nvm))
|
M(pos):set_string("formspec", formspec(CRD(pos).State, pos, nvm))
|
||||||
end,
|
end,
|
||||||
drop = "",
|
|
||||||
node_timer = keep_running,
|
node_timer = keep_running,
|
||||||
on_receive_fields = on_receive_fields,
|
on_receive_fields = on_receive_fields,
|
||||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||||
|
Loading…
Reference in New Issue
Block a user