From ded6941fe9afacfd44d4e83fb782fcf8cb09a92b Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Mon, 28 Jun 2021 22:27:04 +0200 Subject: [PATCH] Add transformer block --- init.lua | 5 +- logic/doorblock.lua | 30 --------- power/laser.lua | 143 ------------------------------------------ ta3_power/akkubox.lua | 1 - 4 files changed, 4 insertions(+), 175 deletions(-) delete mode 100644 power/laser.lua diff --git a/init.lua b/init.lua index 43e9c1c..c0b0359 100644 --- a/init.lua +++ b/init.lua @@ -116,7 +116,6 @@ dofile(MP.."/power/protection.lua") dofile(MP.."/power/power_line.lua") dofile(MP.."/power/ta4_cable.lua") dofile(MP.."/power/ta4_cable_wall_entry.lua") -dofile(MP.."/power/laser.lua") -- Iron Age dofile(MP.."/iron_age/main.lua") @@ -233,6 +232,10 @@ dofile(MP.."/ta3_power/akkubox.lua") dofile(MP.."/ta3_power/axle2power.lua") dofile(MP.."/ta3_power/power2axle.lua") +-- TA4 power based +dofile(MP.."/ta4_power/laser.lua") +dofile(MP.."/ta4_power/transformer.lua") + -- Digtron if minetest.global_exists("digtron") then dofile(MP.."/digtron/battery.lua") diff --git a/logic/doorblock.lua b/logic/doorblock.lua index b231a1b..5dcee0b 100644 --- a/logic/doorblock.lua +++ b/logic/doorblock.lua @@ -106,33 +106,3 @@ minetest.register_craft({ {"group:wood", "", ""}, }, }) - - - -minetest.register_lbm({ - label = "Upgrade doors and gates", - name = "techage:replace_legacy_doors_and_gates", - - nodenames = { - "techage:doorblock19", - "techage:doorblock20", - "techage:gateblock19", - "techage:gateblock20", - }, - - run_at_every_load = false, - - action = function(pos, node) - if node.name == "techage:doorblock19" then - node.name = "techage:doorblock21" - elseif node.name == "techage:doorblock20" then - node.name = "techage:doorblock22" - elseif node.name == "techage:gateblock19" then - node.name = "techage:gateblock21" - elseif node.name == "techage:gateblock20" then - node.name = "techage:gateblock22" - end - minetest.swap_node(pos, node) - end, -}) - diff --git a/power/laser.lua b/power/laser.lua deleted file mode 100644 index 58c89b4..0000000 --- a/power/laser.lua +++ /dev/null @@ -1,143 +0,0 @@ ---[[ - - TechAge - ======= - - Copyright (C) 2019-2021 Joachim Stolberg - - GPL v3 - See LICENSE.txt for more information - - TA4 Laser beam emitter and receiver - -]]-- - --- for lazy programmers -local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end -local S2P = minetest.string_to_pos -local M = minetest.get_meta -local S = techage.S - -local Cable = techage.ElectricCable -local power = networks.power - -minetest.register_node("techage:ta4_laser_emitter", { - description = S("TA4 Laser Beam Emitter"), - tiles = { - -- up, down, right, left, back, front - "techage_filling_ta4.png^techage_frame_ta4_top.png", - "techage_filling_ta4.png^techage_frame_ta4.png", - "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_laser.png", - "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_laser.png", - "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_laser_hole.png", - "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_hole_electric.png", - }, - - after_place_node = function(pos, placer) - local tube_dir = networks.side_to_outdir(pos, "F") - Cable:prepare_pairing(pos, tube_dir, "") - Cable:after_place_node(pos, {tube_dir}) - - local res, pos1, pos2 = techage.renew_laser(pos, true) - if pos1 then - local node = techage.get_node_lvm(pos2) - if node.name == "techage:ta4_laser_receiver" then - Cable:pairing(pos2, "laser") - Cable:pairing(pos, "laser") - else - minetest.chat_send_player(placer:get_player_name(), - S("Valid destination positions:") .. " " .. - P2S(pos1) .. " " .. S("to") .. " " .. P2S(pos2)) - end - else - minetest.chat_send_player(placer:get_player_name(), S("Laser beam error!")) - end - minetest.get_node_timer(pos):start(2) - end, - - on_timer = function(pos, elapsed) - local res, pos1, pos2 = techage.renew_laser(pos) - if pos1 then - local node = techage.get_node_lvm(pos2) - if node.name == "techage:ta4_laser_receiver" then - Cable:pairing(pos2, "laser") - Cable:pairing(pos, "laser") - else - local metadata = M(pos):to_table() - Cable:stop_pairing(pos, metadata, "") - local tube_dir = tonumber(metadata.fields.tube_dir or 0) - Cable:after_dig_node(pos, {tube_dir}) - end - elseif not res then - techage.del_laser(pos) - local metadata = M(pos):to_table() - Cable:stop_pairing(pos, metadata, "") - local tube_dir = tonumber(metadata.fields.tube_dir or 0) - Cable:after_dig_node(pos, {tube_dir}) - end - return true - end, - - after_dig_node = function(pos, oldnode, oldmetadata, digger) - techage.del_laser(pos) - Cable:stop_pairing(pos, oldmetadata, "") - local tube_dir = tonumber(oldmetadata.fields.tube_dir or 0) - Cable:after_dig_node(pos, {tube_dir}) - end, - - paramtype2 = "facedir", - groups = {choppy=2, cracky=2, crumbly=2}, - is_ground_content = false, - sounds = default.node_sound_wood_defaults(), -}) - -minetest.register_node("techage:ta4_laser_receiver", { - description = S("TA4 Laser Beam Receiver"), - tiles = { - -- up, down, right, left, back, front - "techage_filling_ta4.png^techage_frame_ta4_top.png", - "techage_filling_ta4.png^techage_frame_ta4.png", - "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_laser.png", - "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_laser.png", - "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_laser_hole.png", - "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_hole_electric.png", - }, - - after_place_node = function(pos, placer) - local tube_dir = networks.side_to_outdir(pos, "F") - Cable:prepare_pairing(pos, tube_dir, "") - Cable:after_place_node(pos, {tube_dir}) - end, - - after_dig_node = function(pos, oldnode, oldmetadata, digger) - Cable:stop_pairing(pos, oldmetadata, "") - local tube_dir = tonumber(oldmetadata.fields.tube_dir or 0) - Cable:after_dig_node(pos, {tube_dir}) - end, - - paramtype2 = "facedir", - groups = {choppy=2, cracky=2, crumbly=2}, - is_ground_content = false, - sounds = default.node_sound_wood_defaults(), -}) - -power.register_nodes({"techage:ta4_laser_emitter", "techage:ta4_laser_receiver"}, Cable, "special", {"F"}) - -minetest.register_craft({ - output = "techage:ta4_laser_emitter", - recipe = { - {"techage:ta4_carbon_fiber", "dye:blue", "techage:ta4_carbon_fiber"}, - {"techage:electric_cableS", "basic_materials:energy_crystal_simple", "techage:ta4_leds"}, - {"default:steel_ingot", "techage:ta4_wlanchip", "default:steel_ingot"}, - }, -}) - -minetest.register_craft({ - output = "techage:ta4_laser_receiver", - recipe = { - {"techage:ta4_carbon_fiber", "dye:blue", "techage:ta4_carbon_fiber"}, - {"techage:electric_cableS", "basic_materials:gold_wire", "default:obsidian_glass"}, - {"default:steel_ingot", "techage:ta4_wlanchip", "default:steel_ingot"}, - }, -}) - diff --git a/ta3_power/akkubox.lua b/ta3_power/akkubox.lua index 2f2a968..c4899e5 100644 --- a/ta3_power/akkubox.lua +++ b/ta3_power/akkubox.lua @@ -18,7 +18,6 @@ local M = minetest.get_meta local S = techage.S local CYCLE_TIME = 2 -local PWR_PERF = 10 local PWR_CAPA = 2000 local Cable = techage.ElectricCable