mirror of
https://github.com/mt-mods/pipeworks.git
synced 2024-12-28 20:00:27 +01: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:
parent
7b15bdbd1f
commit
75894355d4
@ -83,10 +83,21 @@ pipeworks.register_tube("pipeworks:broken_tube", {
|
|||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
pipeworks.logger(log_msg.." with "..wieldname.." to repair it.")
|
log_msg = log_msg.."with "..wieldname.." to repair it"
|
||||||
|
local nodedef = minetest.registered_nodes[was_node.name]
|
||||||
|
if nodedef then
|
||||||
|
pipeworks.logger(log_msg..".")
|
||||||
|
if nodedef.tube and nodedef.tube.on_repair then
|
||||||
|
nodedef.tube.on_repair(pos, was_node)
|
||||||
|
else
|
||||||
minetest.swap_node(pos, { name = was_node.name, param2 = was_node.param2 })
|
minetest.swap_node(pos, { name = was_node.name, param2 = was_node.param2 })
|
||||||
pipeworks.scan_for_tube_objects(pos)
|
pipeworks.scan_for_tube_objects(pos)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
pipeworks.logger(log_msg.." but original node "..was_node.name.." is not registered anymore.")
|
||||||
|
minetest.chat_send_player(playername, S("This tube cannot be repaired."))
|
||||||
|
end
|
||||||
|
end
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -184,6 +184,18 @@ pipeworks.register_tube("pipeworks:teleport_tube", {
|
|||||||
pos.y = target[d].y
|
pos.y = target[d].y
|
||||||
pos.z = target[d].z
|
pos.z = target[d].z
|
||||||
return pipeworks.meseadjlist
|
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
|
end
|
||||||
},
|
},
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
|
Loading…
Reference in New Issue
Block a user