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
@@ -59,7 +59,6 @@
   end
end
minetest.register_on_placenode(function(pos, node)
   for tier, machine_list in pairs(technic.machines) do
      if machine_list[node.name] ~= nil then
@@ -78,7 +77,6 @@
      end
   end
end)
function technic.get_cable_id(links)
   return (links[6] * 1) + (links[5] * 2)
@@ -120,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"
@@ -146,7 +148,7 @@
   local box_center = {-size, -size, -size, size,  size, size}
   local box_y1 =     {-size, -size, -size, size,  0.5,  size} -- y+
   local box_x1 =     {-size, -size, -size, 0.5,   size, size} -- x+
   local box_z1 =     {-size, -size,  size, size,  size, 0.5}   -- z+
   local box_z1 =     {-size, -size,  size, size,  size, 0.5}  -- z+
   local box_z2 =     {-size, -size, -0.5,  size,  size, size} -- z-
   local box_y2 =     {-size, -0.5,  -size, size,  size, size} -- y-
   local box_x2 =     {-0.5,  -size, -size, size,  size, size} -- x-