From a793747d92d9b1d93153c7fb4e0c82fe90624c78 Mon Sep 17 00:00:00 2001 From: est31 <MTest31@outlook.com> Date: Thu, 18 Jun 2015 04:16:47 +0200 Subject: [PATCH] Move coal furnaces to other/ --- technic/machines/register/cables.lua | 45 ++++++++++++++++++++++++--------------------- 1 files changed, 24 insertions(+), 21 deletions(-) diff --git a/technic/machines/register/cables.lua b/technic/machines/register/cables.lua index 39b3f08..a1e7bc8 100644 --- a/technic/machines/register/cables.lua +++ b/technic/machines/register/cables.lua @@ -1,6 +1,7 @@ -technic.cables = {} +local S = technic.getter +local cable_itstr_to_tier = {} function technic.register_cable(tier, size) local ltier = string.lower(tier) @@ -13,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 @@ -21,7 +22,7 @@ end minetest.register_node("technic:"..ltier.."_cable"..id, { - description = tier.." Cable", + description = S("%s Cable"):format(tier), tiles = {"technic_"..ltier.."_cable.png"}, inventory_image = "technic_"..ltier.."_cable_wield.png", wield_image = "technic_"..ltier.."_cable_wield.png", @@ -35,6 +36,12 @@ type = "fixed", fixed = technic.gen_cable_nodebox(x1, y1, z1, x2, y2, z2, size) }, + on_construct = function() + technic.networks = {} + end, + on_destruct = function() + technic.networks = {} + end, after_place_node = function(pos) local node = minetest.get_node(pos) technic.update_cables(pos, technic.get_cable_tier(node.name)) @@ -52,15 +59,11 @@ end end - minetest.register_on_placenode(function(pos, node) for tier, machine_list in pairs(technic.machines) do - for machine_name, _ in pairs(machine_list) do - if node.name == machine_name then - technic.update_cables(pos, tier, true) - technic.networks = {} - return - end + if machine_list[node.name] ~= nil then + technic.update_cables(pos, tier, true) + technic.networks = {} end end end) @@ -68,16 +71,12 @@ minetest.register_on_dignode(function(pos, node) for tier, machine_list in pairs(technic.machines) do - for machine_name, _ in pairs(machine_list) do - if node.name == machine_name then - technic.update_cables(pos, tier, true) - technic.networks = {} - return - end + if machine_list[node.name] ~= nil then + technic.update_cables(pos, tier, true) + technic.networks = {} end end end) - function technic.get_cable_id(links) return (links[6] * 1) + (links[5] * 2) @@ -119,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" @@ -145,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- -- Gitblit v1.8.0