1
0
mirror of https://github.com/mt-mods/pipeworks.git synced 2025-06-29 23:00:49 +02:00

Assorted changes to tube breaking/repair behavior

* Tubes can now be intentionally broken using a hammer
* Log messages have been improved slightly for tube repair
* Punching a broken tube now causes damage due to the sharp edges
This commit is contained in:
cheapie
2021-03-27 19:51:23 -05:00
parent d2954c5277
commit 7ad991ce40
3 changed files with 72 additions and 25 deletions

View File

@ -55,15 +55,22 @@ end)
-- tube overload mechanism:
-- when the tube's item count (tracked in the above tube_item_count table)
-- exceeds the limit configured per tube, replace it with a broken one.
function pipeworks.break_tube(pos)
local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos)
meta:set_string("the_tube_was", minetest.serialize(node))
minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
pipeworks.scan_for_tube_objects(pos)
end
local crunch_tube = function(pos, cnode, cmeta)
if enable_max_limit then
local h = minetest.hash_node_position(pos)
local itemcount = tube_item_count[h] or 0
if itemcount > max_tube_limit then
cmeta:set_string("the_tube_was", minetest.serialize(cnode))
pipeworks.logger("Warning - a tube at "..minetest.pos_to_string(pos).." broke due to too many items ("..itemcount..")")
minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
pipeworks.scan_for_tube_objects(pos)
pipeworks.break_tube(pos)
end
end
end