From 86ad3e7c6a37699f7f8297a387bf08af74e36629 Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Fri, 1 Apr 2016 22:10:20 -0400 Subject: Update all core mods --- technic/machines/HV/battery_box.lua | 2 +- technic/machines/HV/cables.lua | 4 +- technic/machines/HV/forcefield.lua | 7 +- technic/machines/HV/generator.lua | 2 +- technic/machines/HV/nuclear_reactor.lua | 582 +++++++++++++++-------------- technic/machines/HV/quarry.lua | 5 +- technic/machines/HV/solar_array.lua | 2 +- technic/machines/LV/alloy_furnace.lua | 6 +- technic/machines/LV/battery_box.lua | 6 +- technic/machines/LV/cables.lua | 4 +- technic/machines/LV/cnc.lua | 37 +- technic/machines/LV/compressor.lua | 6 +- technic/machines/LV/electric_furnace.lua | 2 +- technic/machines/LV/extractor.lua | 2 +- technic/machines/LV/generator.lua | 2 +- technic/machines/LV/geothermal.lua | 10 +- technic/machines/LV/grinder.lua | 2 +- technic/machines/LV/music_player.lua | 6 +- technic/machines/LV/solar_array.lua | 2 +- technic/machines/LV/solar_panel.lua | 26 +- technic/machines/LV/water_mill.lua | 8 +- technic/machines/MV/alloy_furnace.lua | 2 +- technic/machines/MV/battery_box.lua | 2 +- technic/machines/MV/cables.lua | 10 +- technic/machines/MV/centrifuge.lua | 6 +- technic/machines/MV/compressor.lua | 2 +- technic/machines/MV/electric_furnace.lua | 4 +- technic/machines/MV/extractor.lua | 2 +- technic/machines/MV/generator.lua | 2 +- technic/machines/MV/grinder.lua | 4 +- technic/machines/MV/power_radiator.lua | 19 +- technic/machines/MV/solar_array.lua | 2 +- technic/machines/MV/tool_workshop.lua | 6 +- technic/machines/MV/wind_mill.lua | 7 +- technic/machines/register/battery_box.lua | 6 +- technic/machines/register/cables.lua | 208 +++-------- technic/machines/register/generator.lua | 10 +- technic/machines/register/machine_base.lua | 12 +- technic/machines/register/solar_array.lua | 5 +- technic/machines/supply_converter.lua | 18 +- technic/machines/switching_station.lua | 17 +- 41 files changed, 488 insertions(+), 579 deletions(-) (limited to 'technic/machines') diff --git a/technic/machines/HV/battery_box.lua b/technic/machines/HV/battery_box.lua index 1e054ec..9093ba9 100644 --- a/technic/machines/HV/battery_box.lua +++ b/technic/machines/HV/battery_box.lua @@ -4,7 +4,7 @@ minetest.register_craft({ recipe = { {'technic:mv_battery_box0', 'technic:mv_battery_box0', 'technic:mv_battery_box0'}, {'technic:mv_battery_box0', 'technic:hv_transformer', 'technic:mv_battery_box0'}, - {'', 'technic:hv_cable0', ''}, + {'', 'technic:hv_cable', ''}, } }) diff --git a/technic/machines/HV/cables.lua b/technic/machines/HV/cables.lua index 25297c8..0b86a23 100644 --- a/technic/machines/HV/cables.lua +++ b/technic/machines/HV/cables.lua @@ -1,9 +1,9 @@ minetest.register_craft({ - output = 'technic:hv_cable0 3', + output = 'technic:hv_cable 3', recipe = { {'homedecor:plastic_sheeting', 'homedecor:plastic_sheeting', 'homedecor:plastic_sheeting'}, - {'technic:mv_cable0', 'technic:mv_cable0', 'technic:mv_cable0'}, + {'technic:mv_cable', 'technic:mv_cable', 'technic:mv_cable'}, {'homedecor:plastic_sheeting', 'homedecor:plastic_sheeting', 'homedecor:plastic_sheeting'}, } }) diff --git a/technic/machines/HV/forcefield.lua b/technic/machines/HV/forcefield.lua index 0f0836d..3bf93b0 100644 --- a/technic/machines/HV/forcefield.lua +++ b/technic/machines/HV/forcefield.lua @@ -15,7 +15,7 @@ minetest.register_craft({ recipe = { {"default:mese", "technic:motor", "default:mese" }, {"technic:deployer_off", "technic:machine_casing", "technic:deployer_off"}, - {"default:mese", "technic:hv_cable0", "default:mese" }, + {"default:mese", "technic:hv_cable", "default:mese" }, } }) @@ -195,7 +195,7 @@ end minetest.register_node("technic:forcefield_emitter_off", { description = S("%s Forcefield Emitter"):format("HV"), tiles = {"technic_forcefield_emitter_off.png"}, - groups = {cracky = 1, technic_machine = 1}, + groups = {cracky = 1, technic_machine = 1, technic_hv = 1}, on_receive_fields = forcefield_receive_fields, on_construct = function(pos) local meta = minetest.get_meta(pos) @@ -215,7 +215,8 @@ minetest.register_node("technic:forcefield_emitter_off", { minetest.register_node("technic:forcefield_emitter_on", { description = S("%s Forcefield Emitter"):format("HV"), tiles = {"technic_forcefield_emitter_on.png"}, - groups = {cracky = 1, technic_machine = 1, not_in_creative_inventory=1}, + groups = {cracky = 1, technic_machine = 1, technic_hv = 1, + not_in_creative_inventory=1}, drop = "technic:forcefield_emitter_off", on_receive_fields = forcefield_receive_fields, on_destruct = function(pos) diff --git a/technic/machines/HV/generator.lua b/technic/machines/HV/generator.lua index aa83590..3fb494b 100644 --- a/technic/machines/HV/generator.lua +++ b/technic/machines/HV/generator.lua @@ -5,7 +5,7 @@ minetest.register_craft({ recipe = { {'technic:carbon_plate', 'technic:mv_generator', 'technic:composite_plate'}, {'pipeworks:tube_1', 'technic:hv_transformer', 'pipeworks:tube_1'}, - {'technic:stainless_steel_ingot', 'technic:hv_cable0', 'technic:stainless_steel_ingot'}, + {'technic:stainless_steel_ingot', 'technic:hv_cable', 'technic:stainless_steel_ingot'}, } }) diff --git a/technic/machines/HV/nuclear_reactor.lua b/technic/machines/HV/nuclear_reactor.lua index 3aa1ba8..c7951ab 100644 --- a/technic/machines/HV/nuclear_reactor.lua +++ b/technic/machines/HV/nuclear_reactor.lua @@ -1,34 +1,34 @@ --- The enriched uranium rod driven EU generator. --- A very large and advanced machine providing vast amounts of power. --- Very efficient but also expensive to run as it needs uranium. (10000EU 86400 ticks (one week)) --- Provides HV EUs that can be down converted as needed. --- --- The nuclear reactor core needs water and a protective shield to work. --- This is checked now and then and if the machine is tampered with... BOOM! - -local burn_ticks = 7 * 24 * 60 * 60 -- (seconds). -local power_supply = 100000 -- EUs -local fuel_type = "technic:uranium_fuel" -- The reactor burns this stuff +--[[ + The enriched uranium rod driven EU generator. +A very large and advanced machine providing vast amounts of power. +Very efficient but also expensive to run as it needs uranium. +Provides 10000 HV EUs for one week (only counted when loaded). + +The nuclear reactor core requires a casing of water and a protective +shield to work. This is checked now and then and if the casing is not +intact the reactor will melt down! +--]] + +local burn_ticks = 7 * 24 * 60 * 60 -- Seconds +local power_supply = 100000 -- EUs +local fuel_type = "technic:uranium_fuel" -- The reactor burns this local S = technic.getter -if not vector.length_square then - vector.length_square = function (v) - return v.x*v.x + v.y*v.y + v.z*v.z - end -end +local reactor_desc = S("@1 Nuclear Reactor Core", S("HV")), --- FIXME: recipe must make more sense like a rod recepticle, steam chamber, HV generator? + +-- FIXME: Recipe should make more sense like a rod recepticle, steam chamber, HV generator? minetest.register_craft({ output = 'technic:hv_nuclear_reactor_core', recipe = { {'technic:carbon_plate', 'default:obsidian_glass', 'technic:carbon_plate'}, {'technic:composite_plate', 'technic:machine_casing', 'technic:composite_plate'}, - {'technic:stainless_steel_ingot', 'technic:hv_cable0', 'technic:stainless_steel_ingot'}, + {'technic:stainless_steel_ingot', 'technic:hv_cable', 'technic:stainless_steel_ingot'}, } }) -local generator_formspec = +local reactor_formspec = "invsize[8,9;]".. "label[0,0;"..S("Nuclear Reactor Rod Compartment").."]".. "list[current_name;src;2,1;3,2;]".. @@ -36,103 +36,111 @@ local generator_formspec = "listring[]" -- "Boxy sphere" -local nodebox = { - { -0.353, -0.353, -0.353, 0.353, 0.353, 0.353 }, -- Box - { -0.495, -0.064, -0.064, 0.495, 0.064, 0.064 }, -- Circle +-x - { -0.483, -0.128, -0.128, 0.483, 0.128, 0.128 }, - { -0.462, -0.191, -0.191, 0.462, 0.191, 0.191 }, - { -0.433, -0.249, -0.249, 0.433, 0.249, 0.249 }, - { -0.397, -0.303, -0.303, 0.397, 0.303, 0.303 }, - { -0.305, -0.396, -0.305, 0.305, 0.396, 0.305 }, -- Circle +-y - { -0.250, -0.432, -0.250, 0.250, 0.432, 0.250 }, - { -0.191, -0.461, -0.191, 0.191, 0.461, 0.191 }, - { -0.130, -0.482, -0.130, 0.130, 0.482, 0.130 }, - { -0.066, -0.495, -0.066, 0.066, 0.495, 0.066 }, - { -0.064, -0.064, -0.495, 0.064, 0.064, 0.495 }, -- Circle +-z - { -0.128, -0.128, -0.483, 0.128, 0.128, 0.483 }, - { -0.191, -0.191, -0.462, 0.191, 0.191, 0.462 }, - { -0.249, -0.249, -0.433, 0.249, 0.249, 0.433 }, - { -0.303, -0.303, -0.397, 0.303, 0.303, 0.397 }, +local node_box = { + {-0.353, -0.353, -0.353, 0.353, 0.353, 0.353}, -- Box + {-0.495, -0.064, -0.064, 0.495, 0.064, 0.064}, -- Circle +-x + {-0.483, -0.128, -0.128, 0.483, 0.128, 0.128}, + {-0.462, -0.191, -0.191, 0.462, 0.191, 0.191}, + {-0.433, -0.249, -0.249, 0.433, 0.249, 0.249}, + {-0.397, -0.303, -0.303, 0.397, 0.303, 0.303}, + {-0.305, -0.396, -0.305, 0.305, 0.396, 0.305}, -- Circle +-y + {-0.250, -0.432, -0.250, 0.250, 0.432, 0.250}, + {-0.191, -0.461, -0.191, 0.191, 0.461, 0.191}, + {-0.130, -0.482, -0.130, 0.130, 0.482, 0.130}, + {-0.066, -0.495, -0.066, 0.066, 0.495, 0.066}, + {-0.064, -0.064, -0.495, 0.064, 0.064, 0.495}, -- Circle +-z + {-0.128, -0.128, -0.483, 0.128, 0.128, 0.483}, + {-0.191, -0.191, -0.462, 0.191, 0.191, 0.462}, + {-0.249, -0.249, -0.433, 0.249, 0.249, 0.433}, + {-0.303, -0.303, -0.397, 0.303, 0.303, 0.397}, } +local SS_OFF = 0 +local SS_DANGER = 1 +local SS_CLEAR = 2 + local reactor_siren = {} -local function siren_set_state(pos, newstate) +local function siren_set_state(pos, state) local hpos = minetest.hash_node_position(pos) local siren = reactor_siren[hpos] if not siren then - if newstate == "off" then return end - siren = {state="off"} + if state == SS_OFF then return end + siren = {state=SS_OFF} reactor_siren[hpos] = siren end - if newstate == "danger" and siren.state ~= "danger" then + if state == SS_DANGER and siren.state ~= SS_DANGER then if siren.handle then minetest.sound_stop(siren.handle) end - siren.handle = minetest.sound_play("technic_hv_nuclear_reactor_siren_danger_loop", {pos=pos, gain=1.5, loop=true, max_hear_distance=48}) - siren.state = "danger" - elseif newstate == "clear" then + siren.handle = minetest.sound_play("technic_hv_nuclear_reactor_siren_danger_loop", + {pos=pos, gain=1.5, loop=true, max_hear_distance=48}) + siren.state = SS_DANGER + elseif state == SS_CLEAR then if siren.handle then minetest.sound_stop(siren.handle) end - local clear_handle = minetest.sound_play("technic_hv_nuclear_reactor_siren_clear", {pos=pos, gain=1.5, loop=false, max_hear_distance=48}) + local clear_handle = minetest.sound_play("technic_hv_nuclear_reactor_siren_clear", + {pos=pos, gain=1.5, loop=false, max_hear_distance=48}) siren.handle = clear_handle - siren.state = "clear" - minetest.after(10, function () - if siren.handle == clear_handle then - minetest.sound_stop(clear_handle) - if reactor_siren[hpos] == siren then - reactor_siren[hpos] = nil - end + siren.state = SS_CLEAR + minetest.after(10, function() + if siren.handle ~= clear_handle then return end + minetest.sound_stop(clear_handle) + if reactor_siren[hpos] == siren then + reactor_siren[hpos] = nil end end) - elseif newstate == "off" and siren.state ~= "off" then + elseif state == SS_OFF and siren.state ~= SS_OFF then if siren.handle then minetest.sound_stop(siren.handle) end - siren.handle = nil reactor_siren[hpos] = nil end end + local function siren_danger(pos, meta) meta:set_int("siren", 1) - siren_set_state(pos, "danger") + siren_set_state(pos, SS_DANGER) end + local function siren_clear(pos, meta) if meta:get_int("siren") ~= 0 then - siren_set_state(pos, "clear") + siren_set_state(pos, SS_CLEAR) meta:set_int("siren", 0) end end --- The standard reactor structure consists of a 9x9x9 cube. A cross --- section through the middle: --- --- CCCC CCCC --- CBBB BBBC --- CBSS SSBC --- CBSWWWSBC --- CBSW#WSBC --- CBSW|WSBC --- CBSS|SSBC --- CBBB|BBBC --- CCCC|CCCC --- C = Concrete, B = Blast-resistant concrete, S = Stainless Steel, --- W = water node, # = reactor core, | = HV cable --- --- The man-hole and the HV cable are only in the middle, and the man-hole --- is optional. --- --- For the reactor to operate and not melt down, it insists on the inner --- 7x7x7 portion (from the core out to the blast-resistant concrete) --- being intact. Intactness only depends on the number of nodes of the --- right type in each layer. The water layer must have water in all but --- at most one node; the steel and blast-resistant concrete layers must --- have the right material in all but at most two nodes. The permitted --- gaps are meant for the cable and man-hole, but can actually be anywhere --- and contain anything. For the reactor to be useful, a cable must --- connect to the core, but it can go in any direction. --- --- The outer concrete layer of the standard structure is not required --- for the reactor to operate. It is noted here because it used to --- be mandatory, and for historical reasons (that it predates the --- implementation of radiation) it needs to continue being adequate --- shielding of legacy reactors. If it ever ceases to be adequate --- shielding for new reactors, legacy ones should be grandfathered. -local reactor_structure_badness = function(pos) +--[[ +The standard reactor structure consists of a 9x9x9 cube. A cross +section through the middle: + + CCCC CCCC + CBBB BBBC + CBSS SSBC + CBSWWWSBC + CBSW#WSBC + CBSW|WSBC + CBSS|SSBC + CBBB|BBBC + CCCC|CCCC + C = Concrete, B = Blast-resistant concrete, S = Stainless Steel, + W = water node, # = reactor core, | = HV cable + +The man-hole and the HV cable are only in the middle, and the man-hole +is optional. + +For the reactor to operate and not melt down, it insists on the inner +7x7x7 portion (from the core out to the blast-resistant concrete) +being intact. Intactness only depends on the number of nodes of the +right type in each layer. The water layer must have water in all but +at most one node; the steel and blast-resistant concrete layers must +have the right material in all but at most two nodes. The permitted +gaps are meant for the cable and man-hole, but can actually be anywhere +and contain anything. For the reactor to be useful, a cable must +connect to the core, but it can go in any direction. + +The outer concrete layer of the standard structure is not required +for the reactor to operate. It is noted here because it used to +be mandatory, and for historical reasons (that it predates the +implementation of radiation) it needs to continue being adequate +shielding of legacy reactors. If it ever ceases to be adequate +shielding for new reactors, legacy ones should be grandfathered. +--]] +local function reactor_structure_badness(pos) local vm = VoxelManip() local pos1 = vector.subtract(pos, 3) local pos2 = vector.add(pos, 3) @@ -179,14 +187,16 @@ local reactor_structure_badness = function(pos) return (25 - waterlayer) + (96 - steellayer) + (216 - blastlayer) end -local function meltdown_reactor(pos) - print("A reactor melted down at "..minetest.pos_to_string(pos)) + +local function melt_down_reactor(pos) + minetest.log("action", "A reactor melted down at "..minetest.pos_to_string(pos)) minetest.set_node(pos, {name="technic:corium_source"}) end + minetest.register_abm({ nodenames = {"technic:hv_nuclear_reactor_core_active"}, - interval = 1, + interval = 4, chance = 1, action = function (pos, node) local meta = minetest.get_meta(pos) @@ -194,14 +204,14 @@ minetest.register_abm({ local accum_badness = meta:get_int("structure_accumulated_badness") if badness == 0 then if accum_badness ~= 0 then - meta:set_int("structure_accumulated_badness", accum_badness - 1) + meta:set_int("structure_accumulated_badness", accum_badness - 4) siren_clear(pos, meta) end else siren_danger(pos, meta) accum_badness = accum_badness + badness - if accum_badness >= 100 then - meltdown_reactor(pos) + if accum_badness >= 25 then + melt_down_reactor(pos) else meta:set_int("structure_accumulated_badness", accum_badness) end @@ -209,40 +219,36 @@ minetest.register_abm({ end, }) -local run = function(pos, node) +local function run(pos, node) local meta = minetest.get_meta(pos) - local machine_name = S("Nuclear %s Generator Core"):format("HV") local burn_time = meta:get_int("burn_time") or 0 if burn_time >= burn_ticks or burn_time == 0 then local inv = meta:get_inventory() if not inv:is_empty("src") then - local srclist = inv:get_list("src") + local src_list = inv:get_list("src") local correct_fuel_count = 0 - for _, srcstack in pairs(srclist) do - if srcstack then - if srcstack:get_name() == fuel_type then - correct_fuel_count = correct_fuel_count + 1 - end + for _, src_stack in pairs(src_list) do + if src_stack and src_stack:get_name() == fuel_type then + correct_fuel_count = correct_fuel_count + 1 end end - -- Check that the reactor is complete as well - -- as the correct number of correct fuel + -- Check that the reactor is complete and has the correct fuel if correct_fuel_count == 6 and - reactor_structure_badness(pos) == 0 then + reactor_structure_badness(pos) == 0 then meta:set_int("burn_time", 1) technic.swap_node(pos, "technic:hv_nuclear_reactor_core_active") meta:set_int("HV_EU_supply", power_supply) - for idx, srcstack in pairs(srclist) do - srcstack:take_item() - inv:set_stack("src", idx, srcstack) + for idx, src_stack in pairs(src_list) do + src_stack:take_item() + inv:set_stack("src", idx, src_stack) end return end end meta:set_int("HV_EU_supply", 0) meta:set_int("burn_time", 0) - meta:set_string("infotext", S("%s Idle"):format(machine_name)) + meta:set_string("infotext", S("%s Idle"):format(reactor_desc)) technic.swap_node(pos, "technic:hv_nuclear_reactor_core") meta:set_int("structure_accumulated_badness", 0) siren_clear(pos, meta) @@ -250,40 +256,33 @@ local run = function(pos, node) burn_time = burn_time + 1 meta:set_int("burn_time", burn_time) local percent = math.floor(burn_time / burn_ticks * 100) - meta:set_string("infotext", machine_name.." ("..percent.."%)") + meta:set_string("infotext", reactor_desc.." ("..percent.."%)") meta:set_int("HV_EU_supply", power_supply) end end minetest.register_node("technic:hv_nuclear_reactor_core", { - description = S("Nuclear %s Generator Core"):format("HV"), - tiles = {"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png", - "technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png", - "technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png"}, - groups = {cracky=1, technic_machine=1}, + description = reactor_desc, + tiles = {"technic_hv_nuclear_reactor_core.png"}, + groups = {cracky=1, technic_machine=1, technic_hv=1}, legacy_facedir_simple = true, sounds = default.node_sound_wood_defaults(), - drawtype="nodebox", + drawtype = "nodebox", paramtype = "light", stack_max = 1, node_box = { type = "fixed", - fixed = nodebox + fixed = node_box }, on_construct = function(pos) local meta = minetest.get_meta(pos) - meta:set_string("infotext", S("Nuclear %s Generator Core"):format("HV")) - meta:set_int("HV_EU_supply", 0) - -- Signal to the switching station that this device burns some - -- sort of fuel and needs special handling - meta:set_int("HV_EU_from_fuel", 1) - meta:set_int("burn_time", 0) - meta:set_string("formspec", generator_formspec) + meta:set_string("infotext", reactor_desc) + meta:set_string("formspec", reactor_formspec) local inv = meta:get_inventory() inv:set_size("src", 6) - end, + end, can_dig = technic.machine_can_dig, - on_destruct = function(pos) siren_set_state(pos, "off") end, + on_destruct = function(pos) siren_set_state(pos, SS_OFF) end, allow_metadata_inventory_put = technic.machine_inventory_put, allow_metadata_inventory_take = technic.machine_inventory_take, allow_metadata_inventory_move = technic.machine_inventory_move, @@ -291,23 +290,22 @@ minetest.register_node("technic:hv_nuclear_reactor_core", { }) minetest.register_node("technic:hv_nuclear_reactor_core_active", { - tiles = {"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png", - "technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png", - "technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png"}, - groups = {cracky=1, technic_machine=1, radioactive=11000, not_in_creative_inventory=1}, + tiles = {"technic_hv_nuclear_reactor_core.png"}, + groups = {cracky=1, technic_machine=1, technic_hv=1, + radioactive=11000, not_in_creative_inventory=1}, legacy_facedir_simple = true, sounds = default.node_sound_wood_defaults(), - drop="technic:hv_nuclear_reactor_core", - drawtype="nodebox", - light_source = 15, + drop = "technic:hv_nuclear_reactor_core", + drawtype = "nodebox", + light_source = 14, paramtype = "light", node_box = { type = "fixed", - fixed = nodebox + fixed = node_box }, can_dig = technic.machine_can_dig, - after_dig_node = meltdown_reactor, - on_destruct = function(pos) siren_set_state(pos, "off") end, + after_dig_node = melt_down_reactor, + on_destruct = function(pos) siren_set_state(pos, SS_OFF) end, allow_metadata_inventory_put = technic.machine_inventory_put, allow_metadata_inventory_take = technic.machine_inventory_take, allow_metadata_inventory_move = technic.machine_inventory_move, @@ -318,10 +316,10 @@ minetest.register_node("technic:hv_nuclear_reactor_core_active", { end, on_timer = function(pos, node) local meta = minetest.get_meta(pos) - + -- Connected back? if meta:get_int("HV_EU_timeout") > 0 then return false end - + local burn_time = meta:get_int("burn_time") or 0 if burn_time >= burn_ticks or burn_time == 0 then @@ -332,7 +330,7 @@ minetest.register_node("technic:hv_nuclear_reactor_core_active", { siren_clear(pos, meta) return false end - + meta:set_int("burn_time", burn_time + 1) return true end, @@ -341,34 +339,36 @@ minetest.register_node("technic:hv_nuclear_reactor_core_active", { technic.register_machine("HV", "technic:hv_nuclear_reactor_core", technic.producer) technic.register_machine("HV", "technic:hv_nuclear_reactor_core_active", technic.producer) --- radioactivity - --- Radiation resistance represents the extent to which a material --- attenuates radiation passing through it; i.e., how good a radiation --- shield it is. This is identified per node type. For materials that --- exist in real life, the radiation resistance value that this system --- uses for a node type consisting of a solid cube of that material is the --- (approximate) number of halvings of ionising radiation that is achieved --- by a metre of the material in real life. This is approximately --- proportional to density, which provides a good way to estimate it. --- Homogeneous mixtures of materials have radiation resistance computed --- by a simple weighted mean. Note that the amount of attenuation that --- a material achieves in-game is not required to be (and is not) the --- same as the attenuation achieved in real life. --- --- Radiation resistance for a node type may be specified in the node --- definition, under the key "radiation_resistance". As an interim --- measure, until node definitions widely include this, this code --- knows a bunch of values for particular node types in several mods, --- and values for groups of node types. The node definition takes --- precedence if it specifies a value. Nodes for which no value at --- all is known are taken to provide no radiation resistance at all; --- this is appropriate for the majority of node types. Only node types --- consisting of a fairly homogeneous mass of material should report --- non-zero radiation resistance; anything with non-uniform geometry --- or complex internal structure should show no radiation resistance. --- Fractional resistance values are permitted; two significant figures --- is the recommended precision. +--[[ +Radioactivity + +Radiation resistance represents the extent to which a material +attenuates radiation passing through it; i.e., how good a radiation +shield it is. This is identified per node type. For materials that +exist in real life, the radiation resistance value that this system +uses for a node type consisting of a solid cube of that material is the +(approximate) number of halvings of ionising radiation that is achieved +by a meter of the material in real life. This is approximately +proportional to density, which provides a good way to estimate it. +Homogeneous mixtures of materials have radiation resistance computed +by a simple weighted mean. Note that the amount of attenuation that +a material achieves in-game is not required to be (and is not) the +same as the attenuation achieved in real life. + +Radiation resistance for a node type may be specified in the node +definition, under the key "radiation_resistance". As an interim +measure, until node definitions widely include this, this code +knows a bunch of values for particular node types in several mods, +and values for groups of node types. The node definition takes +precedence if it specifies a value. Nodes for which no value at +all is known are taken to provide no radiation resistance at all; +this is appropriate for the majority of node types. Only node types +consisting of a fairly homogeneous mass of material should report +non-zero radiation resistance; anything with non-uniform geometry +or complex internal structure should show no radiation resistance. +Fractional resistance values are permitted. +--]] + local default_radiation_resistance_per_node = { ["default:brick"] = 13, ["default:bronzeblock"] = 45, @@ -505,12 +505,13 @@ local default_radiation_resistance_per_group = { wood = 1.7, } local cache_radiation_resistance = {} -local function node_radiation_resistance(nodename) - local eff = cache_radiation_resistance[nodename] +local function node_radiation_resistance(node_name) + local eff = cache_radiation_resistance[node_name] if eff then return eff end - local def = minetest.registered_nodes[nodename] or {groups={}} - eff = def.radiation_resistance or default_radiation_resistance_per_node[nodename] - if not eff then + local def = minetest.registered_nodes[node_name] + eff = def and def.radiation_resistance or + default_radiation_resistance_per_node[node_name] + if def and not eff then for g, v in pairs(def.groups) do if v > 0 and default_radiation_resistance_per_group[g] then eff = default_radiation_resistance_per_group[g] @@ -519,112 +520,114 @@ local function node_radiation_resistance(nodename) end end if not eff then eff = 0 end - cache_radiation_resistance[nodename] = eff + cache_radiation_resistance[node_name] = eff return eff end --- Radioactive nodes cause damage to nearby players. The damage --- effect depends on the intrinsic strength of the radiation source, --- the distance between the source and the player, and the shielding --- effect of the intervening material. These determine a rate of damage; --- total damage caused is the integral of this over time. --- --- In the absence of effective shielding, for a specific source the --- damage rate varies realistically in inverse proportion to the square --- of the distance. (Distance is measured to the player's abdomen, --- not to the nominal player position which corresponds to the foot.) --- However, if the player is inside a non-walkable (liquid or gaseous) --- radioactive node, the nominal distance could go to zero, yielding --- infinite damage. In that case, the player's body is displacing the --- radioactive material, so the effective distance should remain non-zero. --- We therefore apply a lower distance bound of sqrt(0.75) m, which is --- the maximum distance one can get from the node centre within the node. --- --- A radioactive node is identified by being in the "radioactive" group, --- and the group value signifies the strength of the radiation source. --- The group value is the distance in millimetres from a node at which --- an unshielded player will be damaged by 0.25 HP/s. Or, equivalently, --- it is 2000 times the square root of the damage rate in HP/s that an --- unshielded player 1 m away will take. --- --- Shielding is assessed by sampling every 0.25 m along the path --- from the source to the player, ignoring the source node itself. --- The summed shielding values from the sampled nodes yield a measure --- of the total amount of shielding on the path. As in reality, --- shielding causes exponential attenuation of radiation. However, the --- effect is scaled down relative to real life. A metre of a node with --- radiation resistance value R yields attenuation of sqrt(R)*0.1 nepers. --- (In real life it would be about R*0.69 nepers, by the definition --- of the radiation resistance values.) The sqrt part of this formula --- scales down the differences between shielding types, reflecting the --- game's simplification of making expensive materials such as gold --- readily available in cubic metres. The multiplicative factor in the --- formula scales down the difference between shielded and unshielded --- safe distances, avoiding the latter becoming impractically large. --- --- Damage is processed at rates down to 0.25 HP/s, which in the absence of --- shielding is attained at the distance specified by the "radioactive" --- group value. Computed damage rates below 0.25 HP/s result in no --- damage at all to the player. This gives the player an opportunity --- to be safe, and limits the range at which source/player interactions --- need to be considered. -local assumed_abdomen_offset = vector.new(0, 1, 0) -local assumed_abdomen_offset_length = vector.length(assumed_abdomen_offset) +--[[ +Radioactive nodes cause damage to nearby players. The damage +effect depends on the intrinsic strength of the radiation source, +the distance between the source and the player, and the shielding +effect of the intervening material. These determine a rate of damage; +total damage caused is the integral of this over time. + +In the absence of effective shielding, for a specific source the +damage rate varies realistically in inverse proportion to the square +of the distance. (Distance is measured to the player's abdomen, +not to the nominal player position which corresponds to the foot.) +However, if the player is inside a non-walkable (liquid or gaseous) +radioactive node, the nominal distance could go to zero, yielding +infinite damage. In that case, the player's body is displacing the +radioactive material, so the effective distance should remain non-zero. +We therefore apply a lower distance bound of sqrt(0.75), which is +the maximum distance one can get from the node center within the node. + +A radioactive node is identified by being in the "radioactive" group, +and the group value signifies the strength of the radiation source. +The group value is 1000 times the distance from a node at which +an unshielded player will be damaged by 0.25 HP/s. Or, equivalently, +it is 2000 times the square root of the damage rate in HP/s that an +unshielded player 1 node away will take. + +Shielding is assessed by adding the shielding values of all nodes +between the source node and the player, ignoring the source node itself. +As in reality, shielding causes exponential attenuation of radiation. +However, the effect is scaled down relative to real life. A node with +radiation resistance value R yields attenuation of sqrt(R) * 0.1 nepers. +(In real life it would be about R * 0.69 nepers, by the definition +of the radiation resistance values.) The sqrt part of this formula +scales down the differences between shielding types, reflecting the +game's simplification of making expensive materials such as gold +readily available in cubes. The multiplicative factor in the +formula scales down the difference between shielded and unshielded +safe distances, avoiding the latter becoming impractically large. + +Damage is processed at rates down to 0.25 HP/s, which in the absence of +shielding is attained at the distance specified by the "radioactive" +group value. Computed damage rates below 0.25 HP/s result in no +damage at all to the player. This gives the player an opportunity +to be safe, and limits the range at which source/player interactions +need to be considered. +--]] +local abdomen_offset = vector.new(0, 1, 0) +local abdomen_offset_length = vector.length(abdomen_offset) local cache_scaled_shielding = {} -local damage_enabled = minetest.setting_getbool("enable_damage") +local function dmg_player(pos, o, strength) + local pl_pos = vector.add(o:getpos(), abdomen_offset) + local shielding = 0 + local dist = vector.distance(pos, pl_pos) + for ray_pos in technic.trace_node_ray(pos, + vector.direction(pos, pl_pos), dist) do + if not vector.equals(ray_pos, pos) then + local shield_name = minetest.get_node(ray_pos).name + local shield_val = cache_scaled_shielding[sname] + if not shield_val then + shield_val = math.sqrt(node_radiation_resistance(shield_name)) * 0.025 + cache_scaled_shielding[shield_name] = shield_val + end + shielding = shielding + shield_val + end + end + local dmg = (0.25e-6 * strength * strength) / + (math.max(0.75, dist * dist) * math.exp(shielding)) + if dmg >= 0.25 then + local dmg_int = math.floor(dmg) + -- The closer you are to getting one more damage point, + -- the more likely it will be added. + if math.random() < dmg - dmg_int then + dmg_int = dmg_int + 1 + end + if dmg_int > 0 then + o:set_hp(math.max(o:get_hp() - dmg_int, 0)) + end + end +end -if damage_enabled then +local function dmg_abm(pos, node) + local strength = minetest.get_item_group(node.name, "radioactive") + for _, o in pairs(minetest.get_objects_inside_radius(pos, + strength * 0.001 + abdomen_offset_length)) do + if o:is_player() then + dmg_player(pos, o, strength) + end + end +end + + +if minetest.setting_getbool("enable_damage") then minetest.register_abm({ nodenames = {"group:radioactive"}, interval = 1, chance = 1, - action = function (pos, node) - local strength = minetest.registered_nodes[node.name].groups.radioactive - for _, o in ipairs(minetest.get_objects_inside_radius(pos, strength*0.001 + assumed_abdomen_offset_length)) do - if o:is_player() then - local rel = vector.subtract(vector.add(o:getpos(), assumed_abdomen_offset), pos) - local dist_sq = vector.length_square(rel) - local dist = math.sqrt(dist_sq) - local dirstep = dist == 0 and vector.new(0,0,0) or vector.divide(rel, dist*4) - local intpos = pos - local shielding = 0 - for intdist = 0.25, dist, 0.25 do - intpos = vector.add(intpos, dirstep) - local intnodepos = vector.round(intpos) - if not vector.equals(intnodepos, pos) then - local sname = minetest.get_node(intnodepos).name - local sval = cache_scaled_shielding[sname] - if not sval then - sval = math.sqrt(node_radiation_resistance(sname)) * -0.025 - cache_scaled_shielding[sname] = sval - end - shielding = shielding + sval - end - end - local dmg_rate = 0.25e-6 * strength*strength * math.exp(shielding) / math.max(0.75, dist_sq) - if dmg_rate >= 0.25 then - local dmg_int = math.floor(dmg_rate) - if math.random() < dmg_rate-dmg_int then - dmg_int = dmg_int + 1 - end - if dmg_int > 0 then - o:set_hp(math.max(o:get_hp() - dmg_int, 0)) - end - end - end - end - end, + action = dmg_abm, }) end --- radioactive materials that can result from destroying a reactor -local corium_griefing = 1 -if (not technic.config:get_bool("enable_corium_griefing")) then - corium_griefing = 0 -end +-- Radioactive materials that can result from destroying a reactor +local griefing = technic.config:get_bool("enable_corium_griefing") -for _, state in ipairs({ "flowing", "source" }) do +for _, state in pairs({"flowing", "source"}) do minetest.register_node("technic:corium_"..state, { description = S(state == "source" and "Corium Source" or "Flowing Corium"), drawtype = (state == "source" and "liquid" or "flowingliquid"), @@ -652,18 +655,18 @@ for _, state in ipairs({ "flowing", "source" }) do liquid_viscosity = LAVA_VISC, liquid_renewable = false, damage_per_second = 6, - post_effect_color = { a=192, r=80, g=160, b=80 }, + post_effect_color = {a=192, r=80, g=160, b=80}, groups = { liquid = 2, hot = 3, - igniter = corium_griefing, + igniter = (griefing and 1 or 0), radioactive = (state == "source" and 32000 or 16000), not_in_creative_inventory = (state == "flowing" and 1 or nil), }, }) end -if bucket and bucket.register_liquid then +if rawget(_G, "bucket") and bucket.register_liquid then bucket.register_liquid( "technic:corium_source", "technic:corium_flowing", @@ -675,12 +678,11 @@ end minetest.register_node("technic:chernobylite_block", { description = S("Chernobylite Block"), - tiles = { "technic_chernobylite_block.png" }, + tiles = {"technic_chernobylite_block.png"}, is_ground_content = true, - groups = { cracky=1, radioactive=5000, level=2 }, + groups = {cracky=1, radioactive=5000, level=2}, sounds = default.node_sound_stone_defaults(), light_source = 2, - }) minetest.register_abm({ @@ -688,25 +690,36 @@ minetest.register_abm({ neighbors = {"technic:corium_source"}, interval = 1, chance = 1, - action = function (pos, node) + action = function(pos, node) minetest.remove_node(pos) end, }) -if (corium_griefing == 1) then - minetest.register_abm({ - nodenames = {"technic:corium_flowing"}, - interval = 5, - chance = 10, - action = function (pos, node) - minetest.set_node(pos, {name="technic:chernobylite_block"}) - end, - }) +minetest.register_abm({ + nodenames = {"technic:corium_flowing"}, + neighbors = {"group:water"}, + interval = 1, + chance = 1, + action = function(pos, node) + minetest.set_node(pos, {name="technic:chernobylite_block"}) + end, +}) + +minetest.register_abm({ + nodenames = {"technic:corium_flowing"}, + interval = 5, + chance = (griefing and 10 or 1), + action = function(pos, node) + minetest.set_node(pos, {name="technic:chernobylite_block"}) + end, +}) + +if griefing then minetest.register_abm({ - nodenames = { "technic:corium_source", "technic:corium_flowing" }, + nodenames = {"technic:corium_source", "technic:corium_flowing"}, interval = 4, chance = 4, - action = function (pos, node) + action = function(pos, node) for _, offset in ipairs({ vector.new(1,0,0), vector.new(-1,0,0), @@ -721,3 +734,4 @@ if (corium_griefing == 1) then end, }) end + diff --git a/technic/machines/HV/quarry.lua b/technic/machines/HV/quarry.lua index 60805cc..8255676 100644 --- a/technic/machines/HV/quarry.lua +++ b/technic/machines/HV/quarry.lua @@ -5,7 +5,7 @@ minetest.register_craft({ recipe = { {"technic:carbon_plate", "pipeworks:filter", "technic:composite_plate"}, {"technic:motor", "technic:machine_casing", "technic:diamond_drill_head"}, - {"technic:carbon_steel_block", "technic:hv_cable0", "technic:carbon_steel_block"}}, + {"technic:carbon_steel_block", "technic:hv_cable", "technic:carbon_steel_block"}}, output = "technic:quarry", }) @@ -213,7 +213,8 @@ minetest.register_node("technic:quarry", { "technic_carbon_steel_block.png^default_tool_mesepick.png", "technic_carbon_steel_block.png"), paramtype2 = "facedir", - groups = {cracky=2, tubedevice=1, technic_machine = 1}, + groups = {cracky=2, tubedevice=1, technic_machine=1, technic_hv=1}, + connect_sides = {"bottom", "front", "left", "right"}, tube = { connect_sides = {top = 1}, }, diff --git a/technic/machines/HV/solar_array.lua b/technic/machines/HV/solar_array.lua index 414291a..c7de7c8 100644 --- a/technic/machines/HV/solar_array.lua +++ b/technic/machines/HV/solar_array.lua @@ -6,7 +6,7 @@ minetest.register_craft({ recipe = { {'technic:solar_array_mv', 'technic:solar_array_mv', 'technic:solar_array_mv'}, {'technic:carbon_plate', 'technic:hv_transformer', 'technic:composite_plate'}, - {'', 'technic:hv_cable0', ''}, + {'', 'technic:hv_cable', ''}, } }) diff --git a/technic/machines/LV/alloy_furnace.lua b/technic/machines/LV/alloy_furnace.lua index bdf2f31..5e4f7c4 100644 --- a/technic/machines/LV/alloy_furnace.lua +++ b/technic/machines/LV/alloy_furnace.lua @@ -4,9 +4,9 @@ minetest.register_craft({ output = 'technic:lv_alloy_furnace', recipe = { - {'default:brick', 'default:brick', 'default:brick'}, - {'default:brick', 'technic:machine_casing', 'default:brick'}, - {'default:brick', 'technic:lv_cable0', 'default:brick'}, + {'default:brick', 'default:brick', 'default:brick'}, + {'default:brick', 'technic:machine_casing', 'default:brick'}, + {'default:brick', 'technic:lv_cable', 'default:brick'}, } }) diff --git a/technic/machines/LV/battery_box.lua b/technic/machines/LV/battery_box.lua index 429bcd6..066bc9d 100644 --- a/technic/machines/LV/battery_box.lua +++ b/technic/machines/LV/battery_box.lua @@ -2,9 +2,9 @@ minetest.register_craft({ output = 'technic:lv_battery_box0', recipe = { - {'group:wood', 'group:wood', 'group:wood'}, - {'technic:battery', 'technic:machine_casing', 'technic:battery'}, - {'technic:battery', 'technic:lv_cable0', 'technic:battery'}, + {'group:wood', 'group:wood', 'group:wood'}, + {'technic:battery', 'technic:machine_casing', 'technic:battery'}, + {'technic:battery', 'technic:lv_cable', 'technic:battery'}, } }) diff --git a/technic/machines/LV/cables.lua b/technic/machines/LV/cables.lua index e18eae1..d4ed880 100644 --- a/technic/machines/LV/cables.lua +++ b/technic/machines/LV/cables.lua @@ -1,8 +1,8 @@ -minetest.register_alias("lv_cable", "technic:lv_cable0") +minetest.register_alias("lv_cable", "technic:lv_cable") minetest.register_craft({ - output = 'technic:lv_cable0 6', + output = 'technic:lv_cable 6', recipe = { {'default:paper', 'default:paper', 'default:paper'}, {'default:copper_ingot', 'default:copper_ingot', 'default:copper_ingot'}, diff --git a/technic/machines/LV/cnc.lua b/technic/machines/LV/cnc.lua index dd67e9b..58ec6ba 100644 --- a/technic/machines/LV/cnc.lua +++ b/technic/machines/LV/cnc.lua @@ -9,6 +9,17 @@ local S = technic.getter + +minetest.register_craft({ + output = 'technic:cnc', + recipe = { + {'default:glass', 'technic:diamond_drill_head', 'default:glass'}, + {'technic:control_logic_unit', 'technic:machine_casing', 'technic:motor'}, + {'technic:carbon_steel_ingot', 'technic:lv_cable', 'technic:carbon_steel_ingot'}, + }, +}) + + local shape = {} local onesize_products = { slope = 2, @@ -174,16 +185,9 @@ minetest.register_node("technic:cnc", { description = S("%s CNC Machine"):format("LV"), tiles = {"technic_cnc_top.png", "technic_cnc_bottom.png", "technic_cnc_side.png", "technic_cnc_side.png", "technic_cnc_side.png", "technic_cnc_front.png"}, - drawtype = "nodebox", - paramtype = "light", + groups = {cracky=2, technic_machine=1, technic_lv=1}, + connect_sides = {"bottom", "back", "left", "right"}, paramtype2 = "facedir", - node_box = { - type = "fixed", - fixed = { - {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, - }, - }, - groups = {cracky=2, technic_machine=1}, legacy_facedir_simple = true, on_construct = function(pos) local meta = minetest.get_meta(pos) @@ -207,9 +211,10 @@ minetest.register_node("technic:cnc_active", { description = S("%s CNC Machine"):format("LV"), tiles = {"technic_cnc_top_active.png", "technic_cnc_bottom.png", "technic_cnc_side.png", "technic_cnc_side.png", "technic_cnc_side.png", "technic_cnc_front_active.png"}, + groups = {cracky=2, technic_machine=1, technic_lv=1, not_in_creative_inventory=1}, + connect_sides = {"bottom", "back", "left", "right"}, paramtype2 = "facedir", drop = "technic:cnc", - groups = {cracky=2, technic_machine=1, not_in_creative_inventory=1}, legacy_facedir_simple = true, can_dig = technic.machine_can_dig, allow_metadata_inventory_put = technic.machine_inventory_put, @@ -223,15 +228,3 @@ minetest.register_node("technic:cnc_active", { technic.register_machine("LV", "technic:cnc", technic.receiver) technic.register_machine("LV", "technic:cnc_active", technic.receiver) -------------------------- --- CNC Machine Recipe -------------------------- -minetest.register_craft({ - output = 'technic:cnc', - recipe = { - {'default:glass', 'technic:diamond_drill_head', 'default:glass'}, - {'technic:control_logic_unit', 'technic:machine_casing', 'technic:motor'}, - {'technic:carbon_steel_ingot', 'technic:lv_cable0', 'technic:carbon_steel_ingot'}, - }, -}) - diff --git a/technic/machines/LV/compressor.lua b/technic/machines/LV/compressor.lua index e2bde40..67b9f79 100644 --- a/technic/machines/LV/compressor.lua +++ b/technic/machines/LV/compressor.lua @@ -4,9 +4,9 @@ minetest.register_alias("compressor", "technic:lv_compressor") minetest.register_craft({ output = 'technic:lv_compressor', recipe = { - {'default:stone', 'technic:motor', 'default:stone'}, - {'mesecons:piston', 'technic:machine_casing', 'mesecons:piston'}, - {'technic:fine_silver_wire', 'technic:lv_cable0', 'technic:fine_silver_wire'}, + {'default:stone', 'technic:motor', 'default:stone'}, + {'mesecons:piston', 'technic:machine_casing', 'mesecons:piston'}, + {'technic:fine_silver_wire', 'technic:lv_cable', 'technic:fine_silver_wire'}, } }) diff --git a/technic/machines/LV/electric_furnace.lua b/technic/machines/LV/electric_furnace.lua index cc4daff..768f04a 100644 --- a/technic/machines/LV/electric_furnace.lua +++ b/technic/machines/LV/electric_furnace.lua @@ -7,7 +7,7 @@ minetest.register_craft({ recipe = { {'default:cobble', 'default:cobble', 'default:cobble'}, {'default:cobble', 'technic:machine_casing', 'default:cobble'}, - {'default:cobble', 'technic:lv_cable0', 'default:cobble'}, + {'default:cobble', 'technic:lv_cable', 'default:cobble'}, } }) diff --git a/technic/machines/LV/extractor.lua b/technic/machines/LV/extractor.lua index 363d2e3..55d0140 100644 --- a/technic/machines/LV/extractor.lua +++ b/technic/machines/LV/extractor.lua @@ -6,7 +6,7 @@ minetest.register_craft({ recipe = { {'technic:treetap', 'technic:motor', 'technic:treetap'}, {'technic:treetap', 'technic:machine_casing', 'technic:treetap'}, - {'', 'technic:lv_cable0', ''}, + {'', 'technic:lv_cable', ''}, } }) diff --git a/technic/machines/LV/generator.lua b/technic/machines/LV/generator.lua index 999dbc5..dc9815f 100644 --- a/technic/machines/LV/generator.lua +++ b/technic/machines/LV/generator.lua @@ -10,7 +10,7 @@ minetest.register_craft({ recipe = { {'default:stone', 'default:furnace', 'default:stone'}, {'default:stone', 'technic:machine_casing', 'default:stone'}, - {'default:stone', 'technic:lv_cable0', 'default:stone'}, + {'default:stone', 'technic:lv_cable', 'default:stone'}, } }) diff --git a/technic/machines/LV/geothermal.lua b/technic/machines/LV/geothermal.lua index e88d3c9..27f4abc 100644 --- a/technic/machines/LV/geothermal.lua +++ b/technic/machines/LV/geothermal.lua @@ -10,9 +10,9 @@ local S = technic.getter minetest.register_craft({ output = 'technic:geothermal', recipe = { - {'technic:granite', 'default:diamond', 'technic:granite'}, + {'technic:granite', 'default:diamond', 'technic:granite'}, {'technic:fine_copper_wire', 'technic:machine_casing', 'technic:fine_copper_wire'}, - {'technic:granite', 'technic:lv_cable0', 'technic:granite'}, + {'technic:granite', 'technic:lv_cable', 'technic:granite'}, } }) @@ -82,8 +82,9 @@ minetest.register_node("technic:geothermal", { description = S("Geothermal %s Generator"):format("LV"), tiles = {"technic_geothermal_top.png", "technic_machine_bottom.png", "technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"}, + groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, + technic_machine=1, technic_lv=1}, paramtype2 = "facedir", - groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1}, legacy_facedir_simple = true, sounds = default.node_sound_wood_defaults(), on_construct = function(pos) @@ -99,7 +100,8 @@ minetest.register_node("technic:geothermal_active", { tiles = {"technic_geothermal_top_active.png", "technic_machine_bottom.png", "technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"}, paramtype2 = "facedir", - groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1}, + groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, + technic_machine=1, technic_lv=1, not_in_creative_inventory=1}, legacy_facedir_simple = true, sounds = default.node_sound_wood_defaults(), drop = "technic:geothermal", diff --git a/technic/machines/LV/grinder.lua b/technic/machines/LV/grinder.lua index da9ea29..9e45bf4 100644 --- a/technic/machines/LV/grinder.lua +++ b/technic/machines/LV/grinder.lua @@ -5,7 +5,7 @@ minetest.register_craft({ recipe = { {'default:desert_stone', 'default:diamond', 'default:desert_stone'}, {'default:desert_stone', 'technic:machine_casing', 'default:desert_stone'}, - {'technic:granite', 'technic:lv_cable0', 'technic:granite'}, + {'technic:granite', 'technic:lv_cable', 'technic:granite'}, } }) diff --git a/technic/machines/LV/music_player.lua b/technic/machines/LV/music_player.lua index dc7e2d0..262fe5f 100644 --- a/technic/machines/LV/music_player.lua +++ b/technic/machines/LV/music_player.lua @@ -9,7 +9,7 @@ minetest.register_craft({ recipe = { {'technic:chromium_ingot', 'default:diamond', 'technic:chromium_ingot'}, {'default:diamond', 'technic:machine_casing', 'default:diamond'}, - {'default:mossycobble', 'technic:lv_cable0', 'default:mossycobble'}, + {'default:mossycobble', 'technic:lv_cable', 'default:mossycobble'}, } }) @@ -94,7 +94,9 @@ minetest.register_node("technic:music_player", { description = S("%s Music Player"):format("LV"), tiles = {"technic_music_player_top.png", "technic_machine_bottom.png", "technic_music_player_side.png", "technic_music_player_side.png", "technic_music_player_side.png", "technic_music_player_side.png"}, - groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1}, + groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, + technic_machine=1, technic_lv=1}, + connect_sides = {"bottom"}, sounds = default.node_sound_wood_defaults(), on_construct = function(pos) local meta = minetest.get_meta(pos) diff --git a/technic/machines/LV/solar_array.lua b/technic/machines/LV/solar_array.lua index 4d2c3b3..8c1b8f4 100644 --- a/technic/machines/LV/solar_array.lua +++ b/technic/machines/LV/solar_array.lua @@ -10,7 +10,7 @@ minetest.register_craft({ recipe = { {'technic:solar_panel', 'technic:solar_panel', 'technic:solar_panel'}, {'technic:carbon_steel_ingot', 'technic:lv_transformer', 'technic:carbon_steel_ingot'}, - {'', 'technic:lv_cable0', ''}, + {'', 'technic:lv_cable', ''}, } }) diff --git a/technic/machines/LV/solar_panel.lua b/technic/machines/LV/solar_panel.lua index 41dff95..a06ddb8 100644 --- a/technic/machines/LV/solar_panel.lua +++ b/technic/machines/LV/solar_panel.lua @@ -4,6 +4,17 @@ local S = technic.getter + +minetest.register_craft({ + output = 'technic:solar_panel', + recipe = { + {'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer'}, + {'technic:fine_silver_wire', 'technic:lv_cable', 'mesecons_materials:glue'}, + + } +}) + + local run = function(pos, node) -- The action here is to make the solar panel prodice power -- Power is dependent on the light level and the height above ground @@ -24,7 +35,7 @@ local run = function(pos, node) local charge_to_give = math.floor((light + pos1.y) * 3) charge_to_give = math.max(charge_to_give, 0) charge_to_give = math.min(charge_to_give, 200) - meta:set_string("infotext", S("@1 Active (@2 EU)", machine_name, technic.prettynum(charge_to_give))) + meta:set_string("infotext", S("@1 Active (@2 EU)", machine_name, technic.pretty_num(charge_to_give))) meta:set_int("LV_EU_supply", charge_to_give) else meta:set_string("infotext", S("%s Idle"):format(machine_name)) @@ -35,7 +46,9 @@ end minetest.register_node("technic:solar_panel", { tiles = {"technic_solar_panel_top.png", "technic_solar_panel_bottom.png", "technic_solar_panel_side.png", "technic_solar_panel_side.png", "technic_solar_panel_side.png", "technic_solar_panel_side.png"}, - groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1}, + groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, + technic_machine=1, technic_lv=1}, + connect_sides = {"bottom"}, sounds = default.node_sound_wood_defaults(), description = S("Small Solar %s Generator"):format("LV"), active = false, @@ -54,14 +67,5 @@ minetest.register_node("technic:solar_panel", { technic_run = run, }) -minetest.register_craft({ - output = 'technic:solar_panel', - recipe = { - {'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer'}, - {'technic:fine_silver_wire', 'technic:lv_cable0', 'mesecons_materials:glue'}, - - } -}) - technic.register_machine("LV", "technic:solar_panel", technic.producer) diff --git a/technic/machines/LV/water_mill.lua b/technic/machines/LV/water_mill.lua index 9088d1d..c853310 100644 --- a/technic/machines/LV/water_mill.lua +++ b/technic/machines/LV/water_mill.lua @@ -11,7 +11,7 @@ minetest.register_craft({ recipe = { {'technic:marble', 'default:diamond', 'technic:marble'}, {'group:wood', 'technic:machine_casing', 'group:wood'}, - {'technic:marble', 'technic:lv_cable0', 'technic:marble'}, + {'technic:marble', 'technic:lv_cable', 'technic:marble'}, } }) @@ -72,7 +72,8 @@ minetest.register_node("technic:water_mill", { "technic_water_mill_side.png", "technic_water_mill_side.png", "technic_water_mill_side.png", "technic_water_mill_side.png"}, paramtype2 = "facedir", - groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1}, + groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, + technic_machine=1, technic_lv=1}, legacy_facedir_simple = true, sounds = default.node_sound_wood_defaults(), on_construct = function(pos) @@ -89,7 +90,8 @@ minetest.register_node("technic:water_mill_active", { "technic_water_mill_side.png", "technic_water_mill_side.png", "technic_water_mill_side.png", "technic_water_mill_side.png"}, paramtype2 = "facedir", - groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1, not_in_creative_inventory=1}, + groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, + technic_machine=1, technic_lv=1, not_in_creative_inventory=1}, legacy_facedir_simple = true, sounds = default.node_sound_wood_defaults(), drop = "technic:water_mill", diff --git a/technic/machines/MV/alloy_furnace.lua b/technic/machines/MV/alloy_furnace.lua index a1918fd..eaddee0 100644 --- a/technic/machines/MV/alloy_furnace.lua +++ b/technic/machines/MV/alloy_furnace.lua @@ -5,7 +5,7 @@ minetest.register_craft({ recipe = { {'technic:stainless_steel_ingot', 'technic:lv_alloy_furnace', 'technic:stainless_steel_ingot'}, {'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'}, - {'technic:stainless_steel_ingot', 'technic:mv_cable0', 'technic:stainless_steel_ingot'}, + {'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'}, } }) diff --git a/technic/machines/MV/battery_box.lua b/technic/machines/MV/battery_box.lua index 45437c1..d84ec15 100644 --- a/technic/machines/MV/battery_box.lua +++ b/technic/machines/MV/battery_box.lua @@ -5,7 +5,7 @@ minetest.register_craft({ recipe = { {'technic:lv_battery_box0', 'technic:lv_battery_box0', 'technic:lv_battery_box0'}, {'technic:lv_battery_box0', 'technic:mv_transformer', 'technic:lv_battery_box0'}, - {'', 'technic:mv_cable0', ''}, + {'', 'technic:mv_cable', ''}, } }) diff --git a/technic/machines/MV/cables.lua b/technic/machines/MV/cables.lua index b1a34c8..0c1f457 100644 --- a/technic/machines/MV/cables.lua +++ b/technic/machines/MV/cables.lua @@ -1,12 +1,12 @@ -minetest.register_alias("mv_cable", "technic:mv_cable0") +minetest.register_alias("mv_cable", "technic:mv_cable") minetest.register_craft({ - output = 'technic:mv_cable0 3', + output = 'technic:mv_cable 3', recipe ={ - {'technic:rubber', 'technic:rubber', 'technic:rubber'}, - {'technic:lv_cable0', 'technic:lv_cable0', 'technic:lv_cable0'}, - {'technic:rubber', 'technic:rubber', 'technic:rubber'}, + {'technic:rubber', 'technic:rubber', 'technic:rubber'}, + {'technic:lv_cable', 'technic:lv_cable', 'technic:lv_cable'}, + {'technic:rubber', 'technic:rubber', 'technic:rubber'}, } }) diff --git a/technic/machines/MV/centrifuge.lua b/technic/machines/MV/centrifuge.lua index 5bf24bf..a0aad64 100644 --- a/technic/machines/MV/centrifuge.lua +++ b/technic/machines/MV/centrifuge.lua @@ -1,9 +1,9 @@ minetest.register_craft({ output = "technic:mv_centrifuge", recipe = { - { "technic:motor", "technic:copper_plate", "technic:diamond_drill_head" }, - { "technic:copper_plate", "technic:machine_casing", "technic:copper_plate" }, - { "pipeworks:one_way_tube", "technic:mv_cable0", "pipeworks:mese_filter" }, + {"technic:motor", "technic:copper_plate", "technic:diamond_drill_head"}, + {"technic:copper_plate", "technic:machine_casing", "technic:copper_plate" }, + {"pipeworks:one_way_tube", "technic:mv_cable", "pipeworks:mese_filter" }, } }) diff --git a/technic/machines/MV/compressor.lua b/technic/machines/MV/compressor.lua index 5b36cc5..d97739e 100644 --- a/technic/machines/MV/compressor.lua +++ b/technic/machines/MV/compressor.lua @@ -5,7 +5,7 @@ minetest.register_craft({ recipe = { {'technic:stainless_steel_ingot', 'technic:lv_compressor', 'technic:stainless_steel_ingot'}, {'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'}, - {'technic:stainless_steel_ingot', 'technic:mv_cable0', 'technic:stainless_steel_ingot'}, + {'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'}, } }) diff --git a/technic/machines/MV/electric_furnace.lua b/technic/machines/MV/electric_furnace.lua index 1f6b1c2..b1d2dee 100644 --- a/technic/machines/MV/electric_furnace.lua +++ b/technic/machines/MV/electric_furnace.lua @@ -9,8 +9,8 @@ minetest.register_craft({ output = 'technic:mv_electric_furnace', recipe = { {'technic:stainless_steel_ingot', 'technic:lv_electric_furnace', 'technic:stainless_steel_ingot'}, - {'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'}, - {'technic:stainless_steel_ingot', 'technic:mv_cable0', 'technic:stainless_steel_ingot'}, + {'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'}, + {'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'}, } }) diff --git a/technic/machines/MV/extractor.lua b/technic/machines/MV/extractor.lua index fdef5b2..9066bca 100644 --- a/technic/machines/MV/extractor.lua +++ b/technic/machines/MV/extractor.lua @@ -5,7 +5,7 @@ minetest.register_craft({ recipe = { {'technic:stainless_steel_ingot', 'technic:lv_extractor', 'technic:stainless_steel_ingot'}, {'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'}, - {'technic:stainless_steel_ingot', 'technic:mv_cable0', 'technic:stainless_steel_ingot'}, + {'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'}, } }) diff --git a/technic/machines/MV/generator.lua b/technic/machines/MV/generator.lua index 4ae24b8..db9d59f 100644 --- a/technic/machines/MV/generator.lua +++ b/technic/machines/MV/generator.lua @@ -5,7 +5,7 @@ minetest.register_craft({ recipe = { {'technic:stainless_steel_ingot', 'technic:lv_generator', 'technic:stainless_steel_ingot'}, {'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'}, - {'technic:stainless_steel_ingot', 'technic:mv_cable0', 'technic:stainless_steel_ingot'}, + {'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'}, } }) diff --git a/technic/machines/MV/grinder.lua b/technic/machines/MV/grinder.lua index dac536c..19ab372 100644 --- a/technic/machines/MV/grinder.lua +++ b/technic/machines/MV/grinder.lua @@ -4,8 +4,8 @@ minetest.register_craft({ output = 'technic:mv_grinder', recipe = { {'technic:stainless_steel_ingot', 'technic:lv_grinder', 'technic:stainless_steel_ingot'}, - {'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'}, - {'technic:stainless_steel_ingot', 'technic:mv_cable0', 'technic:stainless_steel_ingot'}, + {'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'}, + {'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'}, } }) diff --git a/technic/machines/MV/power_radiator.lua b/technic/machines/MV/power_radiator.lua index 560f8a9..9349e66 100644 --- a/technic/machines/MV/power_radiator.lua +++ b/technic/machines/MV/power_radiator.lua @@ -12,6 +12,16 @@ local power_radius = 12 + +minetest.register_craft({ + output = 'technic:power_radiator 1', + recipe = { + {'technic:stainless_steel_ingot', 'technic:mv_transformer', 'technic:stainless_steel_ingot'}, + {'technic:copper_coil', 'technic:machine_casing', 'technic:copper_coil'}, + {'technic:rubber', 'technic:mv_cable', 'technic:rubber'}, + } +}) + ------------------------------------------------------------------ -- API for inductive powered nodes: -- Use the functions below to set the corresponding callbacks @@ -135,15 +145,6 @@ minetest.register_node("technic:power_radiator", { end }) -minetest.register_craft({ - output = 'technic:power_radiator 1', - recipe = { - {'technic:stainless_steel_ingot', 'technic:mv_transformer', 'technic:stainless_steel_ingot'}, - {'technic:copper_coil', 'technic:machine_casing', 'technic:copper_coil'}, - {'technic:rubber', 'technic:mv_cable0', 'technic:rubber'}, - } -}) - minetest.register_abm({ nodenames = {"technic:power_radiator"}, interval = 1, diff --git a/technic/machines/MV/solar_array.lua b/technic/machines/MV/solar_array.lua index 227d8ee..4077a5c 100644 --- a/technic/machines/MV/solar_array.lua +++ b/technic/machines/MV/solar_array.lua @@ -4,7 +4,7 @@ minetest.register_craft({ recipe = { {'technic:solar_array_lv', 'technic:solar_array_lv', 'technic:solar_array_lv'}, {'technic:carbon_steel_ingot', 'technic:mv_transformer', 'technic:carbon_steel_ingot'}, - {'', 'technic:mv_cable0', ''}, + {'', 'technic:mv_cable', ''}, } }) diff --git a/technic/machines/MV/tool_workshop.lua b/technic/machines/MV/tool_workshop.lua index 318b1ec..4076cc1 100644 --- a/technic/machines/MV/tool_workshop.lua +++ b/technic/machines/MV/tool_workshop.lua @@ -10,7 +10,7 @@ minetest.register_craft({ recipe = { {'group:wood', 'default:diamond', 'group:wood'}, {'mesecons_pistons:piston_sticky_off', 'technic:machine_casing', 'technic:carbon_cloth'}, - {'default:obsidian', 'technic:mv_cable0', 'default:obsidian'}, + {'default:obsidian', 'technic:mv_cable', 'default:obsidian'}, } }) @@ -85,7 +85,9 @@ minetest.register_node("technic:tool_workshop", { paramtype2 = "facedir", tiles = {"technic_workshop_top.png", "technic_machine_bottom.png", "technic_workshop_side.png", "technic_workshop_side.png", "technic_workshop_side.png", "technic_workshop_side.png"}, - groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1, tubedevice=1, tubedevice_receiver=1}, + groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, + technic_machine=1, technic_mv=1, tubedevice=1, tubedevice_receiver=1}, + connect_sides = {"bottom", "back", "left", "right"}, sounds = default.node_sound_wood_defaults(), on_construct = function(pos) local meta = minetest.get_meta(pos) diff --git a/technic/machines/MV/wind_mill.lua b/technic/machines/MV/wind_mill.lua index c553051..1377c67 100644 --- a/technic/machines/MV/wind_mill.lua +++ b/technic/machines/MV/wind_mill.lua @@ -15,7 +15,7 @@ minetest.register_craft({ recipe = { {'', 'technic:motor', ''}, {'technic:carbon_steel_ingot', 'technic:carbon_steel_block', 'technic:carbon_steel_ingot'}, - {'', 'technic:mv_cable0', ''}, + {'', 'technic:mv_cable', ''}, } }) @@ -55,14 +55,15 @@ local run = function(pos, node) meta:set_int("MV_EU_supply", power) end - meta:set_string("infotext", S("@1 (@2 EU)", machine_name, technic.prettynum(power))) + meta:set_string("infotext", S("@1 (@2 EU)", machine_name, technic.pretty_num(power))) end minetest.register_node("technic:wind_mill", { description = S("Wind %s Generator"):format("MV"), tiles = {"technic_carbon_steel_block.png"}, paramtype2 = "facedir", - groups = {cracky=1, technic_machine=1}, + groups = {cracky=1, technic_machine=1, technic_mv=1}, + connect_sides = {"top", "bottom", "back", "left", "right"}, sounds = default.node_sound_stone_defaults(), drawtype = "nodebox", paramtype = "light", diff --git a/technic/machines/register/battery_box.lua b/technic/machines/register/battery_box.lua index 82edca0..953f7af 100644 --- a/technic/machines/register/battery_box.lua +++ b/technic/machines/register/battery_box.lua @@ -151,7 +151,7 @@ function technic.register_battery_box(data) ..":technic_power_meter_fg.png]") local infotext = S("@1 Battery Box: @2/@3", tier, - technic.prettynum(current_charge), technic.prettynum(max_charge)) + technic.pretty_num(current_charge), technic.pretty_num(max_charge)) if eu_input == 0 then infotext = S("%s Idle"):format(infotext) end @@ -159,7 +159,8 @@ function technic.register_battery_box(data) end for i = 0, 8 do - local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1} + local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, + technic_machine=1, ["technic_"..ltier]=1} if i ~= 0 then groups.not_in_creative_inventory = 1 end @@ -178,6 +179,7 @@ function technic.register_battery_box(data) "technic_"..ltier.."_battery_box_side.png^technic_power_meter"..i..".png", "technic_"..ltier.."_battery_box_side.png^technic_power_meter"..i..".png"}, groups = groups, + connect_sides = {"bottom"}, tube = data.tube and tube or nil, paramtype2 = "facedir", sounds = default.node_sound_wood_defaults(), diff --git a/technic/machines/register/cables.lua b/technic/machines/register/cables.lua index a1e7bc8..28984c0 100644 --- a/technic/machines/register/cables.lua +++ b/technic/machines/register/cables.lua @@ -1,177 +1,65 @@ local S = technic.getter -local cable_itstr_to_tier = {} - -function technic.register_cable(tier, size) - local ltier = string.lower(tier) - - for x1 = 0, 1 do - for x2 = 0, 1 do - for y1 = 0, 1 do - for y2 = 0, 1 do - for z1 = 0, 1 do - for z2 = 0, 1 do - local id = technic.get_cable_id({x1, x2, y1, y2, z1, z2}) - - cable_itstr_to_tier["technic:"..ltier.."_cable"..id] = tier - - local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2} - if id ~= 0 then - groups.not_in_creative_inventory = 1 - end - - minetest.register_node("technic:"..ltier.."_cable"..id, { - 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", - groups = groups, - sounds = default.node_sound_wood_defaults(), - drop = "technic:"..ltier.."_cable0", - paramtype = "light", - sunlight_propagates = true, - drawtype = "nodebox", - node_box = { - 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)) - end, - after_dig_node = function(pos, oldnode) - local tier = technic.get_cable_tier(oldnode.name) - technic.update_cables(pos, tier, true) - end - }) - end - end - end - end - end - 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 - technic.update_cables(pos, tier, true) - technic.networks = {} - end - end -end) - - -minetest.register_on_dignode(function(pos, node) - for tier, machine_list in pairs(technic.machines) do - 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) - + (links[4] * 4) + (links[3] * 8) - + (links[2] * 16) + (links[1] * 32) -end - -function technic.update_cables(pos, tier, no_set, secondrun) - local link_positions = { - {x=pos.x+1, y=pos.y, z=pos.z}, - {x=pos.x-1, y=pos.y, z=pos.z}, - {x=pos.x, y=pos.y+1, z=pos.z}, - {x=pos.x, y=pos.y-1, z=pos.z}, - {x=pos.x, y=pos.y, z=pos.z+1}, - {x=pos.x, y=pos.y, z=pos.z-1}} - - local links = {0, 0, 0, 0, 0, 0} - - for i, link_pos in pairs(link_positions) do - local connect_type = technic.cables_should_connect(pos, link_pos, tier) - if connect_type then - links[i] = 1 - -- Have cables next to us update theirselves, - -- but only once. (We don't want to update the entire - -- network or start an infinite loop of updates) - if not secondrun and connect_type == "cable" then - technic.update_cables(link_pos, tier, false, true) - end - end - end - -- We don't want to set ourselves if we have been removed or we are - -- updating a machine - if not no_set then - minetest.set_node(pos, {name="technic:"..string.lower(tier) - .."_cable"..technic.get_cable_id(links)}) - - end -end - +local cable_tier = {} function technic.is_tier_cable(name, tier) - return cable_itstr_to_tier[name] and cable_itstr_to_tier[name] == tier + return cable_tier[name] == tier end - function technic.get_cable_tier(name) - return cable_itstr_to_tier[name] + return cable_tier[name] end - -function technic.cables_should_connect(pos1, pos2, tier) - local name = minetest.get_node(pos2).name - - 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" - end - return false +local function clear_networks() + technic.networks = {} end +function technic.register_cable(tier, size) + local ltier = string.lower(tier) + cable_tier["technic:"..ltier.."_cable"] = tier + + local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2} + + local node_box = { + type = "connected", + fixed = {-size, -size, -size, size, size, size}, + connect_top = {-size, -size, -size, size, 0.5, size}, -- y+ + connect_bottom = {-size, -0.5, -size, size, size, size}, -- y- + connect_front = {-size, -size, -0.5, size, size, size}, -- z- + connect_back = {-size, -size, size, size, size, 0.5 }, -- z+ + connect_left = {-0.5, -size, -size, size, size, size}, -- x- + connect_right = {-size, -size, -size, 0.5, size, size}, -- x+ + } + + minetest.register_node("technic:"..ltier.."_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", + groups = groups, + sounds = default.node_sound_wood_defaults(), + drop = "technic:"..ltier.."_cable", + paramtype = "light", + sunlight_propagates = true, + drawtype = "nodebox", + node_box = node_box, + connects_to = {"technic:"..ltier.."_cable", + "group:technic_"..ltier, "group:technic_all_tiers"}, + on_construct = clear_networks, + on_destruct = clear_networks, + }) +end -function technic.gen_cable_nodebox(x1, y1, z1, x2, y2, z2, size) - -- Nodeboxes - 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_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- - local box = {box_center} - if x1 == 1 then - table.insert(box, box_x1) - end - if y1 == 1 then - table.insert(box, box_y1) - end - if z1 == 1 then - table.insert(box, box_z1) - end - if x2 == 1 then - table.insert(box, box_x2) - end - if y2 == 1 then - table.insert(box, box_y2) - end - if z2 == 1 then - table.insert(box, box_z2) +local function clear_nets_if_machine(pos, node) + for tier, machine_list in pairs(technic.machines) do + if machine_list[node.name] ~= nil then + return clear_networks() + end end - return box end +minetest.register_on_placenode(clear_nets_if_machine) +minetest.register_on_dignode(clear_nets_if_machine) + diff --git a/technic/machines/register/generator.lua b/technic/machines/register/generator.lua index 31c1cef..2cdc336 100644 --- a/technic/machines/register/generator.lua +++ b/technic/machines/register/generator.lua @@ -18,14 +18,14 @@ function technic.register_generator(data) local tier = data.tier local ltier = string.lower(tier) - local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1} - local active_groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1, not_in_creative_inventory=1} + local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, + technic_machine=1, ["technic_"..ltier]=1} if data.tube then groups.tubedevice = 1 groups.tubedevice_receiver = 1 - active_groups.tubedevice = 1 - active_groups.tubedevice_receiver = 1 end + local active_groups = {not_in_creative_inventory = 1} + for k, v in pairs(groups) do active_groups[k] = v end local generator_formspec = "invsize[8,9;]".. @@ -93,6 +93,7 @@ function technic.register_generator(data) "technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_front.png"}, paramtype2 = "facedir", groups = groups, + connect_sides = {"bottom", "back", "left", "right"}, legacy_facedir_simple = true, sounds = default.node_sound_wood_defaults(), tube = data.tube and tube or nil, @@ -122,6 +123,7 @@ function technic.register_generator(data) "technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_front_active.png"}, paramtype2 = "facedir", groups = active_groups, + connect_sides = {"bottom"}, legacy_facedir_simple = true, sounds = default.node_sound_wood_defaults(), tube = data.tube and tube or nil, diff --git a/technic/machines/register/machine_base.lua b/technic/machines/register/machine_base.lua index 0c46261..8cf851b 100644 --- a/technic/machines/register/machine_base.lua +++ b/technic/machines/register/machine_base.lua @@ -15,6 +15,8 @@ local tube = { connect_sides = {left = 1, right = 1, back = 1, top = 1, bottom = 1}, } +local connect_default = {"bottom", "back", "left", "right"} + local function round(v) return math.floor(v + 0.5) end @@ -27,15 +29,13 @@ function technic.register_base_machine(data) local tier = data.tier local ltier = string.lower(tier) - local groups = {cracky = 2, technic_machine = 1} - local active_groups = {cracky = 2, technic_machine = 1, not_in_creative_inventory = 1} + local groups = {cracky = 2, technic_machine = 1, ["technic_"..ltier] = 1} if data.tube then groups.tubedevice = 1 groups.tubedevice_receiver = 1 - active_groups.tubedevice = 1 - active_groups.tubedevice_receiver = 1 end - + local active_groups = {not_in_creative_inventory = 1} + for k, v in pairs(groups) do active_groups[k] = v end local formspec = "invsize[8,9;]".. @@ -145,6 +145,7 @@ function technic.register_base_machine(data) paramtype2 = "facedir", groups = groups, tube = data.tube and tube or nil, + connect_sides = data.connect_sides or connect_default, legacy_facedir_simple = true, sounds = default.node_sound_wood_defaults(), on_construct = function(pos) @@ -179,6 +180,7 @@ function technic.register_base_machine(data) paramtype2 = "facedir", drop = "technic:"..ltier.."_"..machine_name, groups = active_groups, + connect_sides = data.connect_sides or connect_default, legacy_facedir_simple = true, sounds = default.node_sound_wood_defaults(), tube = data.tube and tube or nil, diff --git a/technic/machines/register/solar_array.lua b/technic/machines/register/solar_array.lua index 39f50d2..422bfcf 100644 --- a/technic/machines/register/solar_array.lua +++ b/technic/machines/register/solar_array.lua @@ -30,7 +30,7 @@ function technic.register_solar_array(data) local charge_to_give = math.floor((light + pos.y) * data.power) charge_to_give = math.max(charge_to_give, 0) charge_to_give = math.min(charge_to_give, data.power * 50) - meta:set_string("infotext", S("@1 Active (@2 EU)", machine_name, technic.prettynum(charge_to_give))) + meta:set_string("infotext", S("@1 Active (@2 EU)", machine_name, technic.pretty_num(charge_to_give))) meta:set_int(tier.."_EU_supply", charge_to_give) else meta:set_string("infotext", S("%s Idle"):format(machine_name)) @@ -42,7 +42,8 @@ function technic.register_solar_array(data) tiles = {"technic_"..ltier.."_solar_array_top.png", "technic_"..ltier.."_solar_array_bottom.png", "technic_"..ltier.."_solar_array_side.png", "technic_"..ltier.."_solar_array_side.png", "technic_"..ltier.."_solar_array_side.png", "technic_"..ltier.."_solar_array_side.png"}, - groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1}, + groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1, ["technic_"..ltier]=1}, + connect_sides = {"bottom"}, sounds = default.node_sound_wood_defaults(), description = S("Arrayed Solar %s Generator"):format(tier), active = false, diff --git a/technic/machines/supply_converter.lua b/technic/machines/supply_converter.lua index ffcd40d..32597de 100644 --- a/technic/machines/supply_converter.lua +++ b/technic/machines/supply_converter.lua @@ -30,7 +30,7 @@ local run = function(pos, node) meta:set_int(from.."_EU_supply", 0) meta:set_int(to.."_EU_demand", 0) meta:set_int(to.."_EU_supply", input * remain) - meta:set_string("infotext", S("@1 (@2 @3 -> @4 @5)", machine_name, technic.prettynum(input), from, technic.prettynum(input * remain), to)) + meta:set_string("infotext", S("@1 (@2 @3 -> @4 @5)", machine_name, technic.pretty_num(input), from, technic.pretty_num(input * remain), to)) else meta:set_string("infotext", S("%s Has Bad Cabling"):format(machine_name)) if to then @@ -49,14 +49,10 @@ minetest.register_node("technic:supply_converter", { tiles = {"technic_supply_converter_top.png", "technic_supply_converter_bottom.png", "technic_supply_converter_side.png", "technic_supply_converter_side.png", "technic_supply_converter_side.png", "technic_supply_converter_side.png"}, - groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1}, + groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, + technic_machine=1, technic_all_tiers=1}, + connect_sides = {"top", "bottom"}, sounds = default.node_sound_wood_defaults(), - drawtype = "nodebox", - paramtype = "light", - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, - }, on_construct = function(pos) local meta = minetest.get_meta(pos) meta:set_string("infotext", S("Supply Converter")) @@ -68,9 +64,9 @@ minetest.register_node("technic:supply_converter", { minetest.register_craft({ output = 'technic:supply_converter 1', recipe = { - {'technic:fine_gold_wire', 'technic:rubber', 'technic:doped_silicon_wafer'}, - {'technic:mv_transformer', 'technic:machine_casing', 'technic:lv_transformer'}, - {'technic:mv_cable0', 'technic:rubber', 'technic:lv_cable0'}, + {'technic:fine_gold_wire', 'technic:rubber', 'technic:doped_silicon_wafer'}, + {'technic:mv_transformer', 'technic:machine_casing', 'technic:lv_transformer'}, + {'technic:mv_cable', 'technic:rubber', 'technic:lv_cable'}, } }) diff --git a/technic/machines/switching_station.lua b/technic/machines/switching_station.lua index d6f23a3..f7ec0b6 100644 --- a/technic/machines/switching_station.lua +++ b/technic/machines/switching_station.lua @@ -38,9 +38,9 @@ local S = technic.getter minetest.register_craft({ output = "technic:switching_station", recipe = { - {"", "technic:lv_transformer", ""}, - {"default:copper_ingot", "technic:machine_casing", "default:copper_ingot"}, - {"technic:lv_cable0", "technic:lv_cable0", "technic:lv_cable0"} + {"", "technic:lv_transformer", ""}, + {"default:copper_ingot", "technic:machine_casing", "default:copper_ingot"}, + {"technic:lv_cable", "technic:lv_cable", "technic:lv_cable"} } }) @@ -49,14 +49,9 @@ minetest.register_node("technic:switching_station",{ tiles = {"technic_water_mill_top_active.png", "technic_water_mill_top_active.png", "technic_water_mill_top_active.png", "technic_water_mill_top_active.png", "technic_water_mill_top_active.png", "technic_water_mill_top_active.png"}, - groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2}, + groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_all_tiers=1}, + connect_sides = {"bottom"}, sounds = default.node_sound_wood_defaults(), - drawtype = "nodebox", - paramtype = "light", - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, - }, on_construct = function(pos) local meta = minetest.get_meta(pos) meta:set_string("infotext", S("Switching Station")) @@ -294,7 +289,7 @@ minetest.register_abm({ meta:set_string("infotext", S("@1. Supply: @2 Demand: @3", - machine_name, technic.prettynum(PR_eu_supply), technic.prettynum(RE_eu_demand))) + machine_name, technic.pretty_num(PR_eu_supply), technic.pretty_num(RE_eu_demand))) -- If the PR supply is enough for the RE demand supply them all if PR_eu_supply >= RE_eu_demand then -- cgit v1.2.3