1
0
mirror of https://github.com/mt-mods/pipeworks.git synced 2025-07-03 00:30:34 +02:00

Use on_repair when repairing tube (#37)

* Use on_repair when repairing tube

* Use tube.on_repair

* Verify was_node registration
This commit is contained in:
SX
2022-06-23 19:06:01 +03:00
committed by GitHub
parent 7b15bdbd1f
commit 75894355d4
2 changed files with 30 additions and 7 deletions

View File

@ -184,6 +184,18 @@ pipeworks.register_tube("pipeworks:teleport_tube", {
pos.y = target[d].y
pos.z = target[d].z
return pipeworks.meseadjlist
end,
on_repair = function(pos, node)
local meta = minetest.get_meta(pos)
local channel = meta:get_string("channel")
minetest.swap_node(pos, { name = node.name, param2 = node.param2 })
pipeworks.scan_for_tube_objects(pos)
if channel ~= "" then
local can_receive = meta:get_int("can_receive")
set_tube(pos, channel, can_receive)
local cr_description = (can_receive == 1) and "sending and receiving" or "sending"
meta:set_string("infotext", S("Teleportation Tube @1 on '@2'", cr_description, channel))
end
end
},
on_construct = function(pos)