| | |
| | | |
| | | 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 |
| | |
| | | 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 |
| | |
| | | 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("-----------") |
| | |
| | | |
| | | 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("-----------") |
| | |
| | | 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 |
| | |
| | | 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}, |
| | |
| | | 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) |
| | |
| | | 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") |
| | | |
| | |
| | | |
| | | 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) |
| | |
| | | -- The supply radius |
| | | local rad = power_radius |
| | | |
| | | local meta1 = nil |
| | | local pos1 = {} |
| | | local used_charge = 0 |
| | | |
| | | -- Index all nodes within supply range |
| | |
| | | -- 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 |