est31
2015-06-18 a793747d92d9b1d93153c7fb4e0c82fe90624c78
technic/machines/register/cables.lua
@@ -1,7 +1,7 @@
local S = technic.getter
technic.cables = {}
local cable_itstr_to_tier = {}
function technic.register_cable(tier, size)
   local ltier = string.lower(tier)
@@ -14,7 +14,7 @@
   for z2 = 0, 1 do
      local id = technic.get_cable_id({x1, x2, y1, y2, z1, z2})
      technic.cables["technic:"..ltier.."_cable"..id] = tier
      cable_itstr_to_tier["technic:"..ltier.."_cable"..id] = tier
      local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2}
      if id ~= 0 then
@@ -118,19 +118,23 @@
function technic.is_tier_cable(name, tier)
   return technic.cables[name] and technic.cables[name] == tier
   return cable_itstr_to_tier[name] and cable_itstr_to_tier[name] == tier
end
function technic.get_cable_tier(name)
   return technic.cables[name]
   return cable_itstr_to_tier[name]
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"