diff --git a/basic_machines/distributor.lua b/basic_machines/distributor.lua index 70b58f6..b8b9c3f 100644 --- a/basic_machines/distributor.lua +++ b/basic_machines/distributor.lua @@ -163,7 +163,7 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player) if listname == "src" then CRD(pos).State:start_if_standby(pos) return stack:get_count() - elseif not inv:contains_item(listname, {name = stack:get_name()}) then + elseif list[index]:get_count() == 0 then stack:set_count(1) inv:set_stack(listname, index, stack) return 0 diff --git a/coal_power_station/generator.lua b/coal_power_station/generator.lua index 226a9ef..1c39f1a 100644 --- a/coal_power_station/generator.lua +++ b/coal_power_station/generator.lua @@ -25,8 +25,6 @@ local Cable = techage.ElectricCable local power = techage.power local networks = techage.networks -local INFO = [[Command 'load' returns the current provided power in ku]] - local function formspec(self, pos, nvm) return "size[4,4]".. "box[0,-0.1;3.8,0.5;#c6e8ff]".. @@ -224,9 +222,7 @@ techage.register_node({"techage:generator", "techage:generator_on"}, { end, on_recv_message = function(pos, src, topic, payload) local nvm = techage.get_nvm(pos) - if topic == "info" then - return INFO - elseif topic == "load" then + if topic == "power" then return math.floor((nvm.provided or 0) + 0.5) else return State:on_receive_message(pos, topic, payload) diff --git a/energy_storage/generator.lua b/energy_storage/generator.lua index 4577b38..3da4f8b 100644 --- a/energy_storage/generator.lua +++ b/energy_storage/generator.lua @@ -25,8 +25,6 @@ local Cable = techage.ElectricCable local power = techage.power local networks = techage.networks -local INFO = [[Command 'load' returns the current provided power in ku]] - local function formspec(self, pos, nvm) return "size[4,4]".. "box[0,-0.1;3.8,0.5;#c6e8ff]".. @@ -45,7 +43,10 @@ local function transfer_turbine(pos, topic, payload) end local function can_start(pos, nvm, state) - return (nvm.heatexchanger_trigger or 0) > 0 -- by means of heatexchanger + if (nvm.heatexchanger_trigger or 0) == 0 then -- by means of heatexchanger + return S("storage empty?") + end + return true end local function start_node(pos, nvm, state) @@ -225,9 +226,7 @@ techage.register_node({"techage:ta4_generator", "techage:ta4_generator_on"}, { end, on_recv_message = function(pos, src, topic, payload) local nvm = techage.get_nvm(pos) - if topic == "info" then - return INFO - elseif topic == "load" then + if topic == "power" then return math.floor((nvm.provided or 0) + 0.5) else return State:on_receive_message(pos, topic, payload) diff --git a/energy_storage/heatexchanger1.lua b/energy_storage/heatexchanger1.lua index 0cce45a..826ada8 100644 --- a/energy_storage/heatexchanger1.lua +++ b/energy_storage/heatexchanger1.lua @@ -32,8 +32,6 @@ local Pipe = techage.LiquidPipe local power = techage.power local in_range = techage.in_range -local INFO = [[- Command 'load' returns the storage load in percent]] - local function swap_node(pos, name) local node = techage.get_node_lvm(pos) if node.name == name then @@ -263,6 +261,8 @@ techage.register_node({"techage:heatexchanger1"}, { else return "stopped" end + elseif topic == "power" then + return math.max(nvm.needed or 0, 0) elseif topic == "load" then return techage.power.percent(nvm.capa_max, nvm.capa) elseif topic == "on" then @@ -271,8 +271,6 @@ techage.register_node({"techage:heatexchanger1"}, { elseif topic == "off" then stop_node(pos, techage.get_nvm(pos)) return true - elseif topic == "info" then - return INFO else return "unsupported" end diff --git a/hydrogen/electrolyzer.lua b/hydrogen/electrolyzer.lua index 8580fb1..eca3af6 100644 --- a/hydrogen/electrolyzer.lua +++ b/hydrogen/electrolyzer.lua @@ -280,7 +280,18 @@ minetest.register_node("techage:ta4_electrolyzer_on", { Cable:add_secondary_node_names({"techage:ta4_electrolyzer", "techage:ta4_electrolyzer_on"}) Pipe:add_secondary_node_names({"techage:ta4_electrolyzer", "techage:ta4_electrolyzer_on"}) -techage.register_node({"techage:ta4_electrolyzer", "techage:ta4_electrolyzer_on"}, liquid.recv_message) +techage.register_node({"techage:ta4_electrolyzer", "techage:ta4_electrolyzer_on"}, { + on_recv_message = function(pos, src, topic, payload) + local nvm = techage.get_nvm(pos) + if topic == "load" then + return techage.power.percent(CAPACITY, (nvm.liquid and nvm.liquid.amount) or 0) + elseif topic == "power" then + return math.floor((nvm.taken or 0) + 0.5) + else + return State:on_receive_message(pos, topic, payload) + end + end, +}) minetest.register_craft({ output = "techage:ta4_electrolyzer", diff --git a/hydrogen/fuelcell.lua b/hydrogen/fuelcell.lua index 0ed7ead..c6a83cd 100644 --- a/hydrogen/fuelcell.lua +++ b/hydrogen/fuelcell.lua @@ -271,7 +271,18 @@ minetest.register_node("techage:ta4_fuelcell_on", { Cable:add_secondary_node_names({"techage:ta4_fuelcell", "techage:ta4_fuelcell_on"}) Pipe:add_secondary_node_names({"techage:ta4_fuelcell", "techage:ta4_fuelcell_on"}) -techage.register_node({"techage:ta4_fuelcell", "techage:ta4_fuelcell_on"}, liquid.recv_message) +techage.register_node({"techage:ta4_fuelcell", "techage:ta4_fuelcell_on"}, { + on_recv_message = function(pos, src, topic, payload) + local nvm = techage.get_nvm(pos) + if topic == "load" then + return techage.power.percent(CAPACITY, (nvm.liquid and nvm.liquid.amount) or 0) + elseif topic == "power" then + return math.floor((nvm.given or 0) + 0.5) + else + return State:on_receive_message(pos, topic, payload) + end + end, +}) minetest.register_craft({ output = "techage:ta4_fuelcell", diff --git a/liquids/pump.lua b/liquids/pump.lua index 65e8419..87651b5 100644 --- a/liquids/pump.lua +++ b/liquids/pump.lua @@ -287,29 +287,13 @@ minetest.register_node("techage:t4_pump_on", { techage.register_node({"techage:t3_pump", "techage:t3_pump_on"}, { on_recv_message = function(pos, src, topic, payload) - local resp = State3:on_receive_message(pos, topic, payload) - if resp then - return resp - else - return "unsupported" - end - end, - on_node_load = function(pos) - State3:on_node_load(pos) + return State3:on_receive_message(pos, topic, payload) end, }) techage.register_node({"techage:t4_pump", "techage:t4_pump_on"}, { on_recv_message = function(pos, src, topic, payload) - local resp = State4:on_receive_message(pos, topic, payload) - if resp then - return resp - else - return "unsupported" - end - end, - on_node_load = function(pos) - State4:on_node_load(pos) + return State4:on_receive_message(pos, topic, payload) end, }) diff --git a/oil/drillbox.lua b/oil/drillbox.lua index 69691c1..2aaea20 100644 --- a/oil/drillbox.lua +++ b/oil/drillbox.lua @@ -245,12 +245,7 @@ local tubing = { end end, on_recv_message = function(pos, src, topic, payload) - local resp = CRD(pos).State:on_receive_message(pos, topic, payload) - if resp then - return resp - else - return "unsupported" - end + return CRD(pos).State:on_receive_message(pos, topic, payload) end, on_node_load = function(pos, node) CRD(pos).State:on_node_load(pos) diff --git a/oil/pumpjack.lua b/oil/pumpjack.lua index f021cde..ef7ff30 100644 --- a/oil/pumpjack.lua +++ b/oil/pumpjack.lua @@ -173,12 +173,7 @@ tiles.act = { local tubing = { on_recv_message = function(pos, src, topic, payload) - local resp = CRD(pos).State:on_receive_message(pos, topic, payload) - if resp then - return resp - else - return "unsupported" - end + return CRD(pos).State:on_receive_message(pos, topic, payload) end, on_node_load = function(pos, node) CRD(pos).State:on_node_load(pos) diff --git a/solar/inverter.lua b/solar/inverter.lua index 82a6756..8745438 100644 --- a/solar/inverter.lua +++ b/solar/inverter.lua @@ -195,48 +195,17 @@ minetest.register_node("techage:ta4_solar_inverter", { } }) ---minetest.register_node("techage:ta4_solar_inverterDC", { --- description = S("TA4 Solar Inverter DC"), --- 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_open.png", --- "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_ta4_cable.png", --- "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_inverterDC.png", --- "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_inverterDC.png", --- }, - --- after_place_node = function(pos) --- Solar:after_place_node(pos) --- end, - --- after_dig_node = function(pos, oldnode) --- Solar:after_dig_node(pos) --- end, - --- tubelib2_on_update2 = tubelib2_on_update2, --- paramtype2 = "facedir", --- groups = {cracky=2, crumbly=2, choppy=2}, --- on_rotate = screwdriver.disallow, --- is_ground_content = false, --- networks = { --- ele2 = { --- sides = {L = 1}, --- ntype = "con1", --- }, --- } ---}) - Cable:add_secondary_node_names({"techage:ta4_solar_inverter"}) Solar:add_secondary_node_names({"techage:ta4_solar_inverter"}) techage.register_node({"techage:ta4_solar_inverter"}, { on_recv_message = function(pos, src, topic, payload) - return State:on_receive_message(pos, topic, payload) - end, - on_node_load = function(pos) - State:on_node_load(pos) + local nvm = techage.get_nvm(pos) + if topic == "power" then + return math.floor((nvm.delivered or 0) + 0.5) + else + return State:on_receive_message(pos, topic, payload) + end end, }) diff --git a/ta3_power/akkubox.lua b/ta3_power/akkubox.lua index a14b3e2..9f7b78b 100644 --- a/ta3_power/akkubox.lua +++ b/ta3_power/akkubox.lua @@ -205,8 +205,8 @@ techage.register_node({"techage:ta3_akku"}, { local nvm = techage.get_nvm(pos) if topic == "load" then return techage.power.percent(PWR_CAPA, nvm.capa) - elseif topic == "size" then - return PWR_CAPA + elseif topic == "power" then + return nvm.needed or 0 else return State:on_receive_message(pos, topic, payload) end diff --git a/ta3_power/tiny_generator.lua b/ta3_power/tiny_generator.lua index 75e0c42..3933b14 100644 --- a/ta3_power/tiny_generator.lua +++ b/ta3_power/tiny_generator.lua @@ -283,8 +283,10 @@ Cable:add_secondary_node_names({"techage:tiny_generator", "techage:tiny_generato techage.register_node({"techage:tiny_generator", "techage:tiny_generator_on"}, { on_recv_message = function(pos, src, topic, payload) local nvm = techage.get_nvm(pos) - if topic == "load" then - return power.percent(PWR_CAPA, nvm.provided) + if topic == "power" then + return nvm.provided or 0 + elseif topic == "fuel" then + return techage.fuel.get_fuel_amount(nvm) else return State:on_receive_message(pos, topic, payload) end diff --git a/tools/repairkit.lua b/tools/repairkit.lua index 43409f0..dec96ad 100644 --- a/tools/repairkit.lua +++ b/tools/repairkit.lua @@ -178,13 +178,16 @@ end local function network_check(start_pos, Cable, player_name) local ndef = techage.networks.net_def(start_pos, Cable.tube_type) local outdir = nil + local num = 0 if ndef and ndef.ntype ~= "junc" then outdir = M(start_pos):get_int("outdir") end networks.connection_walk(start_pos, outdir, Cable, function(pos, indir, node) local distance = vector.distance(start_pos, pos) - if distance < 50 then - techage.mark_position(player_name, pos, "check", "#ff0000", 6) + num = num + 1 + if distance < 50 and num < 100 then + local state = techage.power.power_available(pos, Cable) and "power" or "no power" + techage.mark_position(player_name, pos, state, "#ff0000", 6) end end) end @@ -239,6 +242,11 @@ local function read_state(itemstack, user, pointed_thing) load = dump(load) minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": load = "..load.." % ") end + local power = techage.send_single("0", number, "power", nil) + if power and power ~= "" and power ~= "unsupported" then + power = dump(power) + minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": power = "..power.." ku ") + end local owner = M(pos):get_string("owner") or "" if owner ~= "" then minetest.chat_send_player(user:get_player_name(), S("Node owner")..": "..owner.." ") diff --git a/wind_turbine/rotor.lua b/wind_turbine/rotor.lua index 785830b..74a30ce 100644 --- a/wind_turbine/rotor.lua +++ b/wind_turbine/rotor.lua @@ -261,6 +261,8 @@ techage.register_node({"techage:ta4_wind_turbine"}, { else return "stopped" end + elseif topic == "power" then + return nvm.delivered or 0 elseif topic == "on" then nvm.running = true elseif topic == "off" then