From d0001a20c969a67bd12cb242c156026ead22bc65 Mon Sep 17 00:00:00 2001 From: Zefram Date: Sun, 17 Aug 2014 13:40:15 +0100 Subject: [PATCH] Fix visible cable connection for irregular items The switching station and supply converter only semantically connect to cables in particular directions. Make them visually connect only in the matching directions. This is done by special-casing in the cable update logic. If more irregular items arise in the future, or the existing items start to need facedir logic, this should be generalised into something like the connect_sides system for pneumatic tubes. --- manual.md | 4 +--- technic/machines/register/cables.lua | 6 +++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/manual.md b/manual.md index fb21f45..c3570d8 100644 --- a/manual.md +++ b/manual.md @@ -690,9 +690,7 @@ no energy will flow without one. Unlike most electrical items, the switching station is not voltage-specific: the same item will manage a network of any tier. However, also unlike most electrical items, it is picky about the direction in which it is connected to the cable: -the cable must be directly below the switching station. Due to a bug, -the switching station will visually appear to connect to cables on other -sides, but those connections don't do anything. +the cable must be directly below the switching station. Hovering over a network's switching station will show the aggregate energy supply and demand, which is useful for troubleshooting. Electrical energy diff --git a/technic/machines/register/cables.lua b/technic/machines/register/cables.lua index 9ec1cfa..7abdfcb 100644 --- a/technic/machines/register/cables.lua +++ b/technic/machines/register/cables.lua @@ -130,7 +130,11 @@ end function technic.cables_should_connect(pos1, pos2, tier) local name = minetest.get_node(pos2).name - if technic.is_tier_cable(name, tier) then + if name == "technic:switching_station" then + return pos2.y == pos1.y + 1 and "machine" or false + elseif name == "technic:supply_converter" then + return math.abs(pos2.y - pos1.y) == 1 and "machine" or false + elseif technic.is_tier_cable(name, tier) then return "cable" elseif technic.machines[tier][name] then return "machine"