From 521c0b74bba5dd73cf7c0a59fde4a018813e835d Mon Sep 17 00:00:00 2001 From: SmallJoker <mk939@ymail.com> Date: Thu, 24 Nov 2022 21:49:20 +0100 Subject: [PATCH] Fix battery box charging on Windows --- technic/machines/MV/power_radiator.lua | 41 +++++++++++++++++++++-------------------- 1 files changed, 21 insertions(+), 20 deletions(-) diff --git a/technic/machines/MV/power_radiator.lua b/technic/machines/MV/power_radiator.lua index 2617578..329f055 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 @@ -26,7 +36,8 @@ end -- Appliances: --- has_supply: pos of supply node if the appliance has a power radiator near with sufficient power for the demand else "" +-- has_supply: pos of supply node if the appliance has a power radiator near +-- with sufficient power for the demand else "" -- EU_demand: The power demand of the device. -- EU_charge: Actual use. set to EU_demand if active==1 -- active: set to 1 if the device is on @@ -43,7 +54,7 @@ technic.inductive_on_punch_off = function(pos, eu_charge, swapnode) local meta = minetest.get_meta(pos) if meta:get_string("has_supply") ~= "" then - hacky_swap_node(pos, swapnode) + technic.swap_node(pos, swapnode) meta:set_int("active", 1) meta:set_int("EU_charge",eu_charge) --print("-----------") @@ -56,7 +67,7 @@ technic.inductive_on_punch_on = function(pos, eu_charge, swapnode) local meta = minetest.get_meta(pos) - hacky_swap_node(pos, swapnode) + technic.swap_node(pos, swapnode) meta:set_int("active", 0) meta:set_int("EU_charge",eu_charge) --print("-----------") @@ -82,7 +93,7 @@ local nodename = minetest.get_node(pos1).name -- Swap the node and make sure it is off and unpowered if string.sub(nodename, -7) == "_active" then - hacky_swap_node(pos1, string.sub(nodename, 1, -8)) + technic.swap_node(pos1, string.sub(nodename, 1, -8)) meta1:set_int("active", 0) meta1:set_int("EU_charge", 0) end @@ -108,7 +119,7 @@ end minetest.register_node("technic:power_radiator", { - description = "Power Radiator", + description = "MV Power Radiator", tiles = {"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png"}, groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2}, @@ -124,7 +135,7 @@ local meta = minetest.get_meta(pos) meta:set_int("MV_EU_demand",1) -- Demand on the primary side when idle meta:set_int("connected_EU_demand",0) -- Potential demand of connected appliances - meta:set_string("infotext", "Power Radiator") + meta:set_string("infotext", "MV Power Radiator") end, on_dig = function(pos, node, digger) shutdown_inductive_appliances(pos) @@ -135,21 +146,13 @@ end }) -minetest.register_craft({ - output = 'technic:power_radiator 1', - recipe = { - {'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot'}, - {'technic:copper_coil', 'technic:mv_transformer', 'technic:copper_coil'}, - {'technic:rubber', 'technic:mv_cable0', 'technic:rubber'}, - } -}) - minetest.register_abm({ + label = "Machines: run power radiator", nodenames = {"technic:power_radiator"}, interval = 1, chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) - local meta = minetest.env:get_meta(pos) + local meta = minetest.get_meta(pos) local eu_input = meta:get_int("MV_EU_input") local eu_demand = meta:get_int("MV_EU_demand") @@ -158,7 +161,7 @@ if eu_input == 0 then -- No power - meta:set_string("infotext", "Power Radiator is unpowered"); + meta:set_string("infotext", "MV Power Radiator is unpowered"); -- meta:set_int("active", 1) -- used for setting textures someday maybe shutdown_inductive_appliances(pos) meta:set_int("connected_EU_demand", 0) @@ -175,8 +178,6 @@ -- The supply radius local rad = power_radius - local meta1 = nil - local pos1 = {} local used_charge = 0 -- Index all nodes within supply range @@ -201,7 +202,7 @@ -- The appliance has power from this node. Spend power if it is on. used_charge = used_charge + math.floor(meta1:get_int("EU_charge") / eff_factor) end - meta:set_string("infotext", "Power Radiator is powered (" + meta:set_string("infotext", "MV Power Radiator is powered (" ..math.floor(used_charge / max_charge * 100) .."% of maximum power)"); if used_charge == 0 then -- Gitblit v1.8.0