From 54c7267af702dde819d593d8406e472f033ae5b4 Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Mon, 10 Feb 2020 21:20:54 +0100 Subject: [PATCH] fuelcell and electrolyzer reactivated --- basis/liquid_lib.lua | 61 ++---- basis/node_states.lua | 6 +- energy_storage/generator.lua | 2 +- energy_storage/heatexchanger2.lua | 8 +- hydrogen/electrolyzer.lua | 305 ++++++++++++++---------------- hydrogen/fuelcell.lua | 264 ++++++++++++++------------ init.lua | 39 ++-- liquids/liquid_lib.lua | 149 --------------- liquids/tank.lua | 2 +- manuals/manual_ta4_DE.md | 17 +- oil/reboiler.lua | 1 - ta3_power/akkubox.lua | 6 +- ta3_power/tiny_generator.lua | 10 +- 13 files changed, 339 insertions(+), 531 deletions(-) delete mode 100644 liquids/liquid_lib.lua diff --git a/basis/liquid_lib.lua b/basis/liquid_lib.lua index 4a360c7..bffd3c9 100644 --- a/basis/liquid_lib.lua +++ b/basis/liquid_lib.lua @@ -45,52 +45,13 @@ function techage.liquid.formspec(pos, nvm) techage.item_image(1.5, 1, itemname) end ---function techage.liquid.move_item(pos, stack, size, formspec) --- local nvm = techage.get_nvm(pos) --- local inv = M(pos):get_inventory() --- if liquid.is_container_empty(stack:get_name()) then --- fill_container(pos, inv) --- else --- empty_container(pos, inv, size) --- end --- M(pos):set_string("formspec", formspec(pos, nvm)) ---end - function techage.liquid.is_empty(pos) local nvm = techage.get_nvm(pos) local inv = minetest.get_meta(pos):get_inventory() return inv:is_empty("src") and inv:is_empty("dst") and (not nvm.liquid or (nvm.liquid.amount or 0) == 0) end -techage.liquid.tubing = { --- on_pull_item = function(pos, in_dir, num) --- local inv = M(pos):get_inventory() --- if not inv:is_empty("dst") then --- local taken = techage.get_items(inv, "dst", num) --- if not inv:is_empty("src") then --- fill_container(pos, inv) --- end --- return taken --- end --- end, --- on_push_item = function(pos, in_dir, stack) --- local inv = M(pos):get_inventory() --- if inv:room_for_item("src", stack) then --- inv:add_item("src", stack) --- if liquid.is_container_empty(stack:get_name()) then --- fill_container(pos, inv) --- else --- empty_container(pos, inv) --- end --- return true --- end --- return false --- end, --- on_unpull_item = function(pos, in_dir, stack) --- local meta = M(pos) --- local inv = meta:get_inventory() --- return techage.put_items(inv, "dst", stack) --- end, +techage.liquid.recv_message = { on_recv_message = function(pos, src, topic, payload) if topic == "load" then local nvm = techage.get_nvm(pos) @@ -153,7 +114,8 @@ local function empty_container(pos, inv, full_container) local nvm = techage.get_nvm(pos) nvm.liquid = nvm.liquid or {} nvm.liquid.amount = nvm.liquid.amount or 0 - local tank_size = LQD(pos).capa or 0 + local ndef_lqd = LQD(pos) + local tank_size = (ndef_lqd and ndef_lqd.capa) or 0 local ldef = get_liquid_def(full_container) --print("ldef", dump(ldef), "tank_size", tank_size) if ldef and (not nvm.liquid.name or ldef.inv_item == nvm.liquid.name) then @@ -205,14 +167,15 @@ end local function empty_on_punch(pos, nvm, full_container) nvm.liquid = nvm.liquid or {} nvm.liquid.amount = nvm.liquid.amount or 0 - local ldef = get_liquid_def(full_container) - if ldef then - local tank_size = LQD(pos).capa or 0 - if not nvm.liquid.name or ldef.inv_item == nvm.liquid.name then - if nvm.liquid.amount + ldef.size <= tank_size then - nvm.liquid.amount = nvm.liquid.amount + ldef.size - nvm.liquid.name = ldef.inv_item - return {name = ldef.container} + local lqd_def = get_liquid_def(full_container) + local ndef_lqd = LQD(pos) + if lqd_def and ndef_lqd then + local tank_size = ndef_lqd.capa or 0 + if not nvm.liquid.name or lqd_def.inv_item == nvm.liquid.name then + if nvm.liquid.amount + lqd_def.size <= tank_size then + nvm.liquid.amount = nvm.liquid.amount + lqd_def.size + nvm.liquid.name = lqd_def.inv_item + return {name = lqd_def.container} end end end diff --git a/basis/node_states.lua b/basis/node_states.lua index 05f0b0f..84751a8 100644 --- a/basis/node_states.lua +++ b/basis/node_states.lua @@ -298,7 +298,7 @@ function NodeStates:standby(pos, nvm, err_string) end -- special case of standby for pushing nodes -function NodeStates:blocked(pos, nvm) +function NodeStates:blocked(pos, nvm, err_string) local state = nvm.techage_state or STOPPED if state == RUNNING then nvm.techage_state = BLOCKED @@ -307,10 +307,10 @@ function NodeStates:blocked(pos, nvm) end if self.infotext_name then local number = M(pos):get_string("node_number") - M(pos):set_string("infotext", self.infotext_name.." "..number..": blocked") + M(pos):set_string("infotext", self.infotext_name.." "..number..": "..(err_string or "blocked")) end if self.formspec_func then - nvm.ta_state_tooltip = "blocked" + nvm.ta_state_tooltip = err_string or "blocked" M(pos):set_string("formspec", self.formspec_func(self, pos, nvm)) end if self.on_state_change then diff --git a/energy_storage/generator.lua b/energy_storage/generator.lua index 7dbe984..08c2ffa 100644 --- a/energy_storage/generator.lua +++ b/energy_storage/generator.lua @@ -32,7 +32,7 @@ local function formspec(self, pos, nvm) default.gui_bg.. default.gui_bg_img.. default.gui_slots.. - power.formspec_label_bar(0, 0.8, S("power"), PWR_CAPA, nvm.provided).. + power.formspec_label_bar(0, 0.8, S("Electricity"), PWR_CAPA, nvm.provided).. "image_button[2.8,2;1,1;".. self:get_state_button_image(nvm) ..";state_button;]".. "tooltip[2.8,2;1,1;"..self:get_state_tooltip(nvm).."]" end diff --git a/energy_storage/heatexchanger2.lua b/energy_storage/heatexchanger2.lua index a7e950d..30f4247 100644 --- a/energy_storage/heatexchanger2.lua +++ b/energy_storage/heatexchanger2.lua @@ -30,9 +30,9 @@ end local function formspec(self, pos, nvm) local capa_max, capa, needed_max, needed = he1_cmnd(pos, "state") - local arrow = "image[2.5,1.5;1,1;techage_form_arrow_bg.png^[transformR90]" + local arrow = "image[2.5,1.5;1,1;techage_form_arrow_bg.png^[transformR270]" if needed > 0 then - arrow = "image[2.5,1.5;1,1;techage_form_arrow_fg.png^[transformR90]" + arrow = "image[2.5,1.5;1,1;techage_form_arrow_fg.png^[transformR270]" end return "size[6,4]".. default.gui_bg.. @@ -40,8 +40,8 @@ local function formspec(self, pos, nvm) default.gui_slots.. "box[0,-0.1;5.8,0.5;#c6e8ff]".. "label[2,-0.1;"..minetest.colorize( "#000000", S("Heat Exchanger")).."]".. - power.formspec_label_bar(0, 0.8, S("Thermal"), capa_max, capa, "").. - power.formspec_label_bar(3.5, 0.8, S("Input"), needed_max, needed).. + power.formspec_label_bar(0, 0.8, S("Electricity"), needed_max, needed).. + power.formspec_label_bar(3.5, 0.8, S("Thermal"), capa_max, capa, "").. arrow.. "image_button[2.5,3;1,1;".. self:get_state_button_image(nvm) ..";state_button;]".. "tooltip[2.5,3;1,1;"..self:get_state_tooltip(nvm).."]" diff --git a/hydrogen/electrolyzer.lua b/hydrogen/electrolyzer.lua index df916e4..3ef7589 100644 --- a/hydrogen/electrolyzer.lua +++ b/hydrogen/electrolyzer.lua @@ -3,7 +3,7 @@ TechAge ======= - Copyright (C) 2019 Joachim Stolberg + Copyright (C) 2019-2020 Joachim Stolberg GPL v3 See LICENSE.txt for more information @@ -16,44 +16,51 @@ local M = minetest.get_meta local S = techage.S -local Power = techage.ElectricCable +local Cable = techage.ElectricCable local power = techage.power local Pipe = techage.LiquidPipe local liquid = techage.liquid +local networks = techage.networks local CYCLE_TIME = 2 local STANDBY_TICKS = 5 -local PWR_NEEDED = 40 -local PWR_UNITS_PER_HYDROGEN_ITEM = 320 -local CAPACITY = 400 +local PWR_NEEDED = 30 +local PWR_UNITS_PER_HYDROGEN_ITEM = 80 +local CAPACITY = 200 local function formspec(self, pos, nvm) - local update = ((nvm.countdown or 0) > 0 and nvm.countdown) or S("Update") - return "size[8,6.6]".. + local amount = (nvm.liquid and nvm.liquid.amount) or 0 + local lqd_name = (nvm.liquid and nvm.liquid.name) or "techage:liquid" + local arrow = "image[3,1;1,1;techage_form_arrow_bg.png^[transformR270]" + if nvm.running then + arrow = "image[3,1;1,1;techage_form_arrow_fg.png^[transformR270]" + end + if amount > 0 then + lqd_name = lqd_name.." "..amount + end + return "size[6,4]".. default.gui_bg.. default.gui_bg_img.. default.gui_slots.. - "image[0.0,0;1,2;"..power.formspec_power_bar(PWR_NEEDED, nvm.consumed).."]".. - "label[0.2,1.9;"..S("\\[ku\\]").."]".. - "image[2.5,0;1,1;techage_form_arrow_fg.png^[transformR270]".. - "image_button[3.5,1;1,1;".. self:get_state_button_image(nvm) ..";state_button;]".. - "tooltip[3.5,1;1,1;"..self:get_state_tooltip(nvm).."]".. - "button[1.6,1;1.8,1;update;"..update.."]".. - "list[current_player;main;0,2.8;8,4;]" .. - liquid.formspec_liquid(5, 0, nvm).. - default.get_hotbar_bg(0, 2.8) + "box[0,-0.1;5.8,0.5;#c6e8ff]".. + "label[2.5,-0.1;"..minetest.colorize( "#000000", S("Electrolyzer")).."]".. + techage.power.formspec_label_bar(0.1, 0.8, S("Electricity"), PWR_NEEDED, nvm.taken).. + "image[3,1.5;1,1;techage_form_arrow_fg.png^[transformR270]".. + "image_button[3,2.5;1,1;".. self:get_state_button_image(nvm) ..";state_button;]".. + "tooltip[3,2.5;1,1;"..self:get_state_tooltip(nvm).."]".. + techage.item_image(4.5,2, lqd_name) end local function start_node(pos, nvm, state) nvm.running = true - nvm.consumed = 0 - power.secondary_start(pos, nvm, PWR_NEEDED, PWR_NEEDED) + nvm.taken = 0 + power.consumer_start(pos, Cable, CYCLE_TIME) end local function stop_node(pos, nvm, state) nvm.running = false - nvm.consumed = 0 - power.secondary_stop(pos, nvm) + nvm.taken = 0 + power.consumer_stop(pos, Cable) end local State = techage.NodeStates:new({ @@ -62,50 +69,56 @@ local State = techage.NodeStates:new({ cycle_time = CYCLE_TIME, standby_ticks = STANDBY_TICKS, formspec_func = formspec, - infotext_name = "TA4 Electrolyzer", + infotext_name = S("TA4 Electrolyzer"), start_node = start_node, stop_node = stop_node, }) +local function on_power(pos) + local nvm = techage.get_nvm(pos) + State:start(pos, nvm) + nvm.running = true +end + +local function on_nopower(pos) + local nvm = techage.get_nvm(pos) + State:stop(pos, nvm) + nvm.running = false +end + + +local function generating(pos, nvm) + nvm.num_pwr_units = nvm.num_pwr_units or 0 + nvm.countdown = nvm.countdown or 0 + print("electrolyzer", nvm.running, nvm.taken, nvm.num_pwr_units, nvm.liquid.amount) + if nvm.taken > 0 then + nvm.num_pwr_units = nvm.num_pwr_units + (nvm.taken or 0) + if nvm.num_pwr_units >= PWR_UNITS_PER_HYDROGEN_ITEM then + nvm.liquid.amount = nvm.liquid.amount + 1 + nvm.liquid.name = "techage:hydrogen" + nvm.num_pwr_units = nvm.num_pwr_units - PWR_UNITS_PER_HYDROGEN_ITEM + end + end +end + -- converts power into hydrogen local function node_timer(pos, elapsed) local nvm = techage.get_nvm(pos) - nvm.num_pwr_units = nvm.num_pwr_units or 0 - nvm.countdown = nvm.countdown or 0 nvm.liquid = nvm.liquid or {} nvm.liquid.amount = nvm.liquid.amount or 0 - print("electrolyzer", nvm.running, nvm.consumed, nvm.num_pwr_units, nvm.liquid.amount) - if nvm.running then - if techage.needs_power(nvm) then - nvm.consumed = -power.secondary_alive(pos, nvm, 0, 1) - --print("nvm.consumed", nvm.consumed) - if nvm.consumed > 0 then - if nvm.liquid.amount < CAPACITY then - nvm.num_pwr_units = nvm.num_pwr_units + nvm.consumed - if nvm.num_pwr_units >= PWR_UNITS_PER_HYDROGEN_ITEM then - nvm.liquid.amount = nvm.liquid.amount + 1 - nvm.liquid.name = "techage:hydrogen" - nvm.num_pwr_units = nvm.num_pwr_units - PWR_UNITS_PER_HYDROGEN_ITEM - State:keep_running(pos, nvm, 1, 0) -- count items - end - else - State:blocked(pos, nvm) - power.secondary_stop(pos, nvm) - end - end - else - nvm.consumed = -power.secondary_alive(pos, nvm, 1, 1) - if nvm.liquid.amount < CAPACITY then - State:start(pos, nvm) - power.secondary_start(pos, nvm, PWR_NEEDED, PWR_NEEDED) - end - end + + if nvm.liquid.amount < CAPACITY then + nvm.taken = power.consumer_alive(pos, Cable, CYCLE_TIME) + generating(pos, nvm) + State:keep_running(pos, nvm, 1, 0) -- count items + else + State:blocked(pos, nvm, S("full")) + power.consumer_stop(pos, Cable) end - if nvm.countdown > 0 then - nvm.countdown = nvm.countdown - 1 + if techage.is_activeformspec(pos) then M(pos):set_string("formspec", formspec(State, pos, nvm)) end - return nvm.running or nvm.countdown > 0 + return true end local function on_receive_fields(pos, formname, fields, player) @@ -114,85 +127,100 @@ local function on_receive_fields(pos, formname, fields, player) end local nvm = techage.get_nvm(pos) State:state_button_event(pos, nvm, fields) - - nvm.countdown = 10 M(pos):set_string("formspec", formspec(State, pos, nvm)) - minetest.get_node_timer(pos):start(CYCLE_TIME) end -local function allow_metadata_inventory(pos, listname, index, stack, player) - if minetest.is_protected(pos, player:get_player_name()) then - return 0 - end - if stack:get_name() == "techage:hydrogen" then - return stack:get_count() - end - return 0 -end - -local function on_rightclick(pos) +local function on_rightclick(pos, node, clicker) local nvm = techage.get_nvm(pos) - nvm.countdown = 10 + techage.set_activeformspec(pos, clicker) M(pos):set_string("formspec", formspec(State, pos, nvm)) - minetest.get_node_timer(pos):start(CYCLE_TIME) end +local function after_place_node(pos) + local nvm = techage.get_nvm(pos) + nvm.running = false + nvm.num_pwr_units = 0 + local number = techage.add_node(pos, "techage:ta4_electrolyzer2") + State:node_init(pos, nvm, number) + local node = minetest.get_node(pos) + M(pos):set_int("in_dir", techage.side_to_indir("R", node.param2)) + Pipe:after_place_node(pos) + Cable:after_place_node(pos) +end + +local function after_dig_node(pos, oldnode, oldmetadata, digger) + Pipe:after_dig_node(pos) + Cable:after_dig_node(pos) +end + +local function tubelib2_on_update2(pos, outdir, tlib2, node) + if tlib2.tube_type == "pipe2" then + liquid.update_network(pos, outdir, tlib2) + else + power.update_network(pos, outdir, tlib2) + end +end + +local netw_def = { + pipe2 = { + sides = {R = 1}, -- Pipe connection sides + ntype = "tank", + }, + ele1 = { + sides = {L = 1}, -- Cable connection sides + ntype = "con2", + on_power = on_power, + on_nopower = on_nopower, + nominal = PWR_NEEDED, + }, +} + +local liquid_def = { + capa = CAPACITY, + peek = liquid.srv_peek, + put = function(pos, indir, name, amount) + local leftover = liquid.srv_put(pos, indir, name, amount) + if techage.is_activeformspec(pos) then + local nvm = techage.get_nvm(pos) + M(pos):set_string("formspec", formspec(State, pos, nvm)) + end + return leftover + end, + take = function(pos, indir, name, amount) + amount, name = liquid.srv_take(pos, indir, name, amount) + if techage.is_activeformspec(pos) then + local nvm = techage.get_nvm(pos) + M(pos):set_string("formspec", formspec(State, pos, nvm)) + end + return amount, name + end +} + minetest.register_node("techage:ta4_electrolyzer2", { description = S("TA4 Electrolyzer"), tiles = { -- up, down, right, left, back, front "techage_filling_ta4.png^techage_frame_ta4_top.png^techage_appl_arrow.png", "techage_filling_ta4.png^techage_frame_ta4.png", - "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_outp.png", + "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_hole_pipe.png", "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_hole_electric.png", "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_electrolyzer.png^techage_appl_ctrl_unit.png^[transformFX", "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_electrolyzer.png^techage_appl_ctrl_unit.png", }, - on_construct = function(pos) - local nvm = techage.get_nvm(pos) - local number = techage.add_node(pos, "techage:ta4_electrolyzer2") - nvm.running = false - nvm.num_pwr_units = 0 - State:node_init(pos, nvm, number) - local meta = M(pos) - meta:set_string("formspec", formspec(State, pos, nvm)) - local inv = meta:get_inventory() - inv:set_size('src', 1) - inv:set_size('dst', 1) - end, - - tubelib2_on_update2 = function(pos, outdir, tlib2, node) - liquid.update_network(pos, outdir) - end, - can_dig = function(pos, player) - local inv = M(pos):get_inventory() - return inv:is_empty("dst") + if minetest.is_protected(pos, player:get_player_name()) then + return false + end + return liquid.is_empty(pos) end, - liquid = { - capa = CAPACITY, - peek = liquid.srv_peek, - put = function(pos, indir, name, amount) - local leftover = liquid.srv_put(pos, indir, name, amount) - local inv = M(pos):get_inventory() - if not inv:is_empty("src") and inv:is_empty("dst") then - liquid.fill_container(pos, inv) - end - return leftover - end, - take = liquid.srv_take, - }, - networks = { - pipe2 = { - sides = {R = 1}, -- Pipe connection sides - ntype = "tank", - }, - }, - - allow_metadata_inventory_put = allow_metadata_inventory, - allow_metadata_inventory_take = allow_metadata_inventory, + after_place_node = after_place_node, + after_dig_node = after_dig_node, + tubelib2_on_update2 = tubelib2_on_update2, + on_punch = liquid.on_punch, + networks = netw_def, + liquid = liquid_def, on_receive_fields = on_receive_fields, on_timer = node_timer, on_rightclick = on_rightclick, @@ -209,7 +237,7 @@ minetest.register_node("techage:ta4_electrolyzer2_on", { -- up, down, right, left, back, front "techage_filling_ta4.png^techage_frame_ta4_top.png^techage_appl_arrow.png", "techage_filling_ta4.png^techage_frame_ta4.png", - "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_outp.png", + "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_hole_pipe.png", "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_hole_electric.png", { image = "techage_filling4_ta4.png^techage_frame4_ta4.png^techage_appl_electrolyzer4.png^techage_appl_ctrl_unit4.png^[transformFX", @@ -233,36 +261,14 @@ minetest.register_node("techage:ta4_electrolyzer2_on", { }, }, - tubelib2_on_update2 = function(pos, outdir, tlib2, node) - liquid.update_network(pos, outdir) - end, - - liquid = { - capa = CAPACITY, - peek = liquid.srv_peek, - put = function(pos, indir, name, amount) - local leftover = liquid.srv_put(pos, indir, name, amount) - local inv = M(pos):get_inventory() - if not inv:is_empty("src") and inv:is_empty("dst") then - liquid.fill_container(pos, inv) - end - return leftover - end, - take = liquid.srv_take, - }, - networks = { - pipe2 = { - sides = {R = 1}, -- Pipe connection sides - ntype = "tank", - }, - }, - - allow_metadata_inventory_put = allow_metadata_inventory, - allow_metadata_inventory_take = allow_metadata_inventory, + tubelib2_on_update2 = tubelib2_on_update2, + networks = netw_def, + liquid = liquid_def, on_receive_fields = on_receive_fields, + on_punch = liquid.on_punch, on_timer = node_timer, on_rightclick = on_rightclick, - + paramtype2 = "facedir", groups = {not_in_creative_inventory=1}, on_rotate = screwdriver.disallow, @@ -272,26 +278,9 @@ minetest.register_node("techage:ta4_electrolyzer2_on", { light_source = 6, }) --- Register for power -techage.power.register_node({"techage:ta4_electrolyzer2", "techage:ta4_electrolyzer2_on"}, { - conn_sides = {"L"}, - power_network = Power, - after_place_node = function(pos) - local node = minetest.get_node(pos) - local indir = techage.side_to_indir("R", node.param2) - M(pos):set_int("in_dir", indir) - Pipe:after_place_node(pos) - end, - after_dig_node = function(pos, oldnode, oldmetadata, digger) - Pipe:after_dig_node(pos) - end, -}) - --- Register for tubes -techage.register_node({"techage:ta4_electrolyzer2", "techage:ta4_electrolyzer2_on"}, liquid.tubing) - --- Register for pipes -Pipe:add_secondary_node_names({"techage:ta3_tank", "techage:ta4_tank", "techage:oiltank"}) +Cable:add_secondary_node_names({"techage:ta4_electrolyzer2", "techage:ta4_electrolyzer2_on"}) +Pipe:add_secondary_node_names({"techage:ta4_electrolyzer2", "techage:ta4_electrolyzer2_on"}) +techage.register_node({"techage:ta4_electrolyzer2", "techage:ta4_electrolyzer2_on"}, liquid.recv_message) minetest.register_craft({ output = "techage:ta4_electrolyzer2", diff --git a/hydrogen/fuelcell.lua b/hydrogen/fuelcell.lua index 569a69e..b8c5505 100644 --- a/hydrogen/fuelcell.lua +++ b/hydrogen/fuelcell.lua @@ -3,7 +3,7 @@ TechAge ======= - Copyright (C) 2019 Joachim Stolberg + Copyright (C) 2019-2020 Joachim Stolberg GPL v3 See LICENSE.txt for more information @@ -16,42 +16,53 @@ local M = minetest.get_meta local S = techage.S -local Power = techage.ElectricCable +local Cable = techage.ElectricCable local power = techage.power +local Pipe = techage.LiquidPipe +local liquid = techage.liquid +local networks = techage.networks local CYCLE_TIME = 2 local STANDBY_TICKS = 5 -local PWR_CAPA = 40 -local PWR_UNITS_PER_HYDROGEN_ITEM = 240 +local PWR_CAPA = 25 +local PWR_UNITS_PER_HYDROGEN_ITEM = 80 +local CAPACITY = 100 local function formspec(self, pos, nvm) - return "size[8,6.6]".. + local amount = (nvm.liquid and nvm.liquid.amount) or 0 + local lqd_name = (nvm.liquid and nvm.liquid.name) or "techage:liquid" + local arrow = "image[3,1;1,1;techage_form_arrow_bg.png^[transformR270]" + if nvm.running then + arrow = "image[3,1;1,1;techage_form_arrow_fg.png^[transformR270]" + end + if amount > 0 then + lqd_name = lqd_name.." "..amount + end + return "size[6,4]".. default.gui_bg.. default.gui_bg_img.. default.gui_slots.. - "list[context;src;0.5,0;2,2;]".. - "image[4,0;1,1;techage_form_arrow_fg.png^[transformR270]".. - "image_button[5,1;1,1;".. self:get_state_button_image(nvm) ..";state_button;]".. - "button[3.1,1;1.8,1;update;"..S("Update").."]".. - "image[6.5,0;1,2;"..power.formspec_power_bar(PWR_CAPA, nvm.provided).."]".. - "label[6.7,1.9;"..S("\\[ku\\]").."]".. - "list[current_player;main;0,2.8;8,4;]" .. - "listring[current_player;main]".. - "listring[context;src]" .. - "listring[current_player;main]".. - default.get_hotbar_bg(0, 2.8) + "box[0,-0.1;5.8,0.5;#c6e8ff]".. + "label[2.5,-0.1;"..minetest.colorize( "#000000", S("Fuel Cell")).."]".. + techage.item_image(0.5,2, lqd_name).. + "image[2,1.5;1,1;techage_form_arrow_fg.png^[transformR270]".. + "image_button[2,2.5;1,1;".. self:get_state_button_image(nvm) ..";state_button;]".. + "tooltip[2,2.5;1,1;"..self:get_state_tooltip(nvm).."]".. + techage.power.formspec_label_bar(3.5, 0.8, S("Electricity"), PWR_CAPA, nvm.provided) end local function start_node(pos, nvm, state) nvm.running = true nvm.provided = 0 - power.generator_start(pos, nvm, PWR_CAPA) + local outdir = M(pos):get_int("outdir") + power.generator_start(pos, Cable, CYCLE_TIME, outdir) end local function stop_node(pos, nvm, state) nvm.running = false nvm.provided = 0 - power.generator_stop(pos, nvm) + local outdir = M(pos):get_int("outdir") + power.generator_stop(pos, Cable, outdir) end local State = techage.NodeStates:new({ @@ -60,15 +71,16 @@ local State = techage.NodeStates:new({ cycle_time = CYCLE_TIME, standby_ticks = STANDBY_TICKS, formspec_func = formspec, - infotext_name = "TA4 Fuel Cell", + infotext_name = S("TA4 Fuel Cell"), start_node = start_node, stop_node = stop_node, }) -local function get_hydrogen(pos) - local inv = M(pos):get_inventory() - local taken = inv:remove_item("src", ItemStack("techage:hydrogen")) - return taken:get_count() > 0 +local function has_hydrogen(nvm) + nvm.liquid = nvm.liquid or {} + nvm.liquid.amount = nvm.liquid.amount or 0 + nvm.num_pwr_units = nvm.num_pwr_units or 0 + return nvm.num_pwr_units > 0 or (nvm.liquid.amount > 0 and nvm.liquid.name == "techage:hydrogen") end local function contains_hydrogen(pos) @@ -76,37 +88,31 @@ local function contains_hydrogen(pos) return inv:contains_item("src", ItemStack("techage:hydrogen")) end +local function consuming(pos, nvm) + if nvm.num_pwr_units <= 0 then + nvm.num_pwr_units = nvm.num_pwr_units + PWR_UNITS_PER_HYDROGEN_ITEM + nvm.liquid.amount = nvm.liquid.amount - 1 + end + nvm.num_pwr_units = nvm.num_pwr_units - nvm.given +end + -- converts hydrogen into power local function node_timer(pos, elapsed) local nvm = techage.get_nvm(pos) - nvm.num_pwr_units = nvm.num_pwr_units or 0 - --print("fuelcell", nvm.running, nvm.provided, nvm.num_pwr_units, techage.get_state_string(nvm)) - if nvm.running then - if techage.needs_power(nvm) then - if nvm.num_pwr_units <= 0 then - if get_hydrogen(pos) then - State:keep_running(pos, nvm, 1, 0) -- count items - nvm.num_pwr_units = nvm.num_pwr_units + PWR_UNITS_PER_HYDROGEN_ITEM - else - State:standby(pos, nvm) - nvm.provided = 0 - power.generator_stop(pos, nvm) - M(pos):set_string("formspec", formspec(State, pos, nvm)) - return true - end - end - nvm.provided = power.generator_alive(pos, nvm) - nvm.num_pwr_units = nvm.num_pwr_units - nvm.provided - else - if contains_hydrogen(pos) then - State:start(pos, nvm) - nvm.provided = 0 - power.generator_start(pos, nvm, PWR_CAPA) - M(pos):set_string("formspec", formspec(State, pos, nvm)) - end - end + print("fuelcell", nvm.running, nvm.given, nvm.num_pwr_units) + if has_hydrogen(nvm) then + local outdir = M(pos):get_int("outdir") + nvm.given = power.generator_alive(pos, Cable, CYCLE_TIME, outdir) + consuming(pos, nvm) + State:keep_running(pos, nvm, 1, 0) -- count items + else + State:standby(pos, nvm) + nvm.given = 0 end - return nvm.running + if techage.is_activeformspec(pos) then + M(pos):set_string("formspec", formspec(State, pos, nvm)) + end + return true end local function on_receive_fields(pos, formname, fields, player) @@ -115,27 +121,73 @@ local function on_receive_fields(pos, formname, fields, player) end local nvm = techage.get_nvm(pos) State:state_button_event(pos, nvm, fields) - - if fields.update then - M(pos):set_string("formspec", formspec(State, pos, nvm)) - end -end - -local function allow_metadata_inventory(pos, listname, index, stack, player) - if minetest.is_protected(pos, player:get_player_name()) then - return 0 - end - if stack:get_name() == "techage:hydrogen" then - return stack:get_count() - end - return 0 -end - -local function on_rightclick(pos) - local nvm = techage.get_nvm(pos) M(pos):set_string("formspec", formspec(State, pos, nvm)) end +local function on_rightclick(pos, node, clicker) + local nvm = techage.get_nvm(pos) + techage.set_activeformspec(pos, clicker) + M(pos):set_string("formspec", formspec(State, pos, nvm)) +end + +local function after_place_node(pos) + local nvm = techage.get_nvm(pos) + nvm.running = false + nvm.num_pwr_units = 0 + local number = techage.add_node(pos, "techage:ta4_fuelcell") + State:node_init(pos, nvm, number) + local node = minetest.get_node(pos) + M(pos):set_int("outdir", networks.side_to_outdir(pos, "R")) + Pipe:after_place_node(pos) + Cable:after_place_node(pos) +end + +local function after_dig_node(pos, oldnode, oldmetadata, digger) + Pipe:after_dig_node(pos) + Cable:after_dig_node(pos) +end + +local function tubelib2_on_update2(pos, outdir, tlib2, node) + if tlib2.tube_type == "pipe2" then + liquid.update_network(pos, outdir, tlib2) + else + power.update_network(pos, outdir, tlib2) + end +end + +local netw_def = { + pipe2 = { + sides = {L = 1}, -- Pipe connection sides + ntype = "tank", + }, + ele1 = { + sides = {R = 1}, -- Cable connection sides + ntype = "gen2", + nominal = PWR_CAPA, + }, +} + +local liquid_def = { + capa = CAPACITY, + peek = liquid.srv_peek, + put = function(pos, indir, name, amount) + local leftover = liquid.srv_put(pos, indir, name, amount) + if techage.is_activeformspec(pos) then + local nvm = techage.get_nvm(pos) + M(pos):set_string("formspec", formspec(State, pos, nvm)) + end + return leftover + end, + take = function(pos, indir, name, amount) + amount, name = liquid.srv_take(pos, indir, name, amount) + if techage.is_activeformspec(pos) then + local nvm = techage.get_nvm(pos) + M(pos):set_string("formspec", formspec(State, pos, nvm)) + end + return amount, name + end +} + minetest.register_node("techage:ta4_fuelcell", { description = S("TA4 Fuel Cell"), tiles = { @@ -143,30 +195,24 @@ minetest.register_node("techage:ta4_fuelcell", { "techage_filling_ta4.png^techage_frame_ta4_top.png^techage_appl_arrow.png", "techage_filling_ta4.png^techage_frame_ta4.png", "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_hole_electric.png", - "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_inp.png", + "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_hole_pipe.png", "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_fuelcell.png^techage_appl_ctrl_unit.png^[transformFX", "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_fuelcell.png^techage_appl_ctrl_unit.png", }, - on_construct = function(pos) - local nvm = techage.get_nvm(pos) - local number = techage.add_node(pos, "techage:ta4_fuelcell") - nvm.running = false - nvm.num_pwr_units = 0 - State:node_init(pos, nvm, number) - local meta = M(pos) - meta:set_string("formspec", formspec(State, pos, nvm)) - local inv = meta:get_inventory() - inv:set_size('src', 4) - end, - can_dig = function(pos, player) - local inv = M(pos):get_inventory() - return inv:is_empty("src") + if minetest.is_protected(pos, player:get_player_name()) then + return false + end + return liquid.is_empty(pos) end, - allow_metadata_inventory_put = allow_metadata_inventory, - allow_metadata_inventory_take = allow_metadata_inventory, + after_place_node = after_place_node, + after_dig_node = after_dig_node, + tubelib2_on_update2 = tubelib2_on_update2, + on_punch = liquid.on_punch, + networks = netw_def, + liquid = liquid_def, on_receive_fields = on_receive_fields, on_timer = node_timer, on_rightclick = on_rightclick, @@ -184,7 +230,7 @@ minetest.register_node("techage:ta4_fuelcell_on", { "techage_filling_ta4.png^techage_frame_ta4_top.png^techage_appl_arrow.png", "techage_filling_ta4.png^techage_frame_ta4.png", "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_hole_electric.png", - "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_inp.png", + "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_hole_pipe.png", { image = "techage_filling4_ta4.png^techage_frame4_ta4.png^techage_appl_fuelcell4.png^techage_appl_ctrl_unit4.png^[transformFX", backface_culling = false, @@ -207,9 +253,11 @@ minetest.register_node("techage:ta4_fuelcell_on", { }, }, - allow_metadata_inventory_put = allow_metadata_inventory, - allow_metadata_inventory_take = allow_metadata_inventory, + tubelib2_on_update2 = tubelib2_on_update2, + networks = netw_def, + liquid = liquid_def, on_receive_fields = on_receive_fields, + on_punch = liquid.on_punch, on_timer = node_timer, on_rightclick = on_rightclick, @@ -222,43 +270,9 @@ minetest.register_node("techage:ta4_fuelcell_on", { light_source = 6, }) -techage.power.register_node({"techage:ta4_fuelcell", "techage:ta4_fuelcell_on"}, { - conn_sides = {"R"}, - power_network = Power, - after_place_node = function(pos) - local node = minetest.get_node(pos) - local indir = techage.side_to_indir("L", node.param2) - M(pos):set_int("in_dir", indir) - end, -}) - -techage.register_node({"techage:ta4_fuelcell", "techage:ta4_fuelcell_on"}, { - on_pull_item = function(pos, in_dir, num) - local meta = minetest.get_meta(pos) - if meta:get_int("in_dir") == in_dir then - local inv = M(pos):get_inventory() - return techage.get_items(inv, "src", num) - end - end, - on_push_item = function(pos, in_dir, stack) - local meta = minetest.get_meta(pos) - if meta:get_int("in_dir") == in_dir then - local inv = M(pos):get_inventory() - State:start_if_standby(pos) - return techage.put_items(inv, "src", stack) - end - end, - on_unpull_item = function(pos, in_dir, stack) - local meta = minetest.get_meta(pos) - if meta:get_int("in_dir") == in_dir then - local inv = M(pos):get_inventory() - return techage.put_items(inv, "src", stack) - end - end, - on_recv_message = function(pos, src, topic, payload) - return State:on_receive_message(pos, topic, payload) - end, -}) +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) minetest.register_craft({ output = "techage:ta4_fuelcell", diff --git a/init.lua b/init.lua index c153e85..ec902c2 100644 --- a/init.lua +++ b/init.lua @@ -121,7 +121,7 @@ else dofile(MP.."/coal_power_station/cooler.lua") dofile(MP.."/coal_power_station/oilfirebox.lua") --- -- Industrial Furnace + -- Industrial Furnace dofile(MP.."/furnace/firebox.lua") dofile(MP.."/furnace/cooking.lua") dofile(MP.."/furnace/furnace_top.lua") @@ -144,7 +144,7 @@ else dofile(MP.."/lamps/industriallamp2.lua") dofile(MP.."/lamps/industriallamp3.lua") --- -- Oil + -- Oil dofile(MP.."/oil/explore.lua") dofile(MP.."/oil/tower.lua") dofile(MP.."/oil/drillbox.lua") @@ -153,7 +153,7 @@ else dofile(MP.."/oil/reboiler.lua") -- dofile(MP.."/oil/gasflare.lua") --- TA3 power based + -- TA3 power based dofile(MP.."/ta3_power/tiny_generator.lua") dofile(MP.."/ta3_power/akkubox.lua") @@ -177,19 +177,19 @@ else -- Test dofile(MP.."/recipe_checker.lua") dofile(MP.."/.test/sink.lua") - dofile(MP.."/.test/meta_node.lua") + --dofile(MP.."/.test/meta_node.lua") -- Solar dofile(MP.."/solar/minicell.lua") dofile(MP.."/solar/solarcell.lua") dofile(MP.."/solar/inverter.lua") --- -- Wind + -- Wind dofile(MP.."/wind_turbine/rotor.lua") dofile(MP.."/wind_turbine/pillar.lua") dofile(MP.."/wind_turbine/signallamp.lua") --- -- TA4 Energy Storage + -- TA4 Energy Storage dofile(MP.."/energy_storage/heatexchanger3.lua") dofile(MP.."/energy_storage/heatexchanger2.lua") dofile(MP.."/energy_storage/heatexchanger1.lua") @@ -198,16 +198,15 @@ else dofile(MP.."/energy_storage/inlet.lua") dofile(MP.."/energy_storage/nodes.lua") --- -- Chemistry + -- Chemistry dofile(MP.."/chemistry/ta4_reactor.lua") dofile(MP.."/chemistry/ta4_stand.lua") dofile(MP.."/chemistry/ta4_doser.lua") --- -- Hydrogen --- dofile(MP.."/hydrogen/fuelcellstack.lua") --- dofile(MP.."/hydrogen/electrolyzer.lua") --- dofile(MP.."/hydrogen/fuelcell.lua") --- dofile(MP.."/hydrogen/legacy.lua") + -- Hydrogen + dofile(MP.."/hydrogen/fuelcellstack.lua") + dofile(MP.."/hydrogen/electrolyzer.lua") + dofile(MP.."/hydrogen/fuelcell.lua") -- Items dofile(MP.."/items/barrel.lua") @@ -228,20 +227,4 @@ else if techage.basalt_stone_enabled then dofile(MP.."/items/basalt.lua") end - --- dofile(MP.."/power3/electric_cable.lua") --- dofile(MP.."/power3/node_api.lua") --- dofile(MP.."/power3/distribution.lua") --- dofile(MP.."/power3/schedule.lua") --- dofile(MP.."/power3/hud_debug.lua") --- dofile(MP.."/power3/junctionbox.lua") --- dofile(MP.."/power3/ele3_sink.lua") --- dofile(MP.."/power3/ele3_source.lua") --- dofile(MP.."/power3/accu.lua") --- dofile(MP.."/power3/power_terminal.lua") --- dofile(MP.."/power3/powerswitchbox.lua") --- dofile(MP.."/power3/drive_axle.lua") --- dofile(MP.."/power3/gearbox.lua") --- dofile(MP.."/power3/axle_sink.lua") --- dofile(MP.."/power3/axle_source.lua") end diff --git a/liquids/liquid_lib.lua b/liquids/liquid_lib.lua deleted file mode 100644 index 743a5c2..0000000 --- a/liquids/liquid_lib.lua +++ /dev/null @@ -1,149 +0,0 @@ ---[[ - - TechAge - ======= - - Copyright (C) 2019-2020 Joachim Stolberg - - GPL v3 - See LICENSE.txt for more information - - Liquid lib - -]]-- - -local M = minetest.get_meta -local S = techage.S -local P2S = minetest.pos_to_string -local liquid = techage.liquid -local LQD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).liquid end - - -local function help(x, y) - local tooltip = S("To add liquids punch\nthe tank\nwith a liquid container") - return "label["..x..","..y..";"..minetest.colorize("#000000", minetest.formspec_escape("[?]")).."]".. - "tooltip["..x..","..y..";0.5,0.5;"..tooltip..";#0C3D32;#FFFFFF]" -end - -function techage.liquid.formspec(pos, nvm) - local title = S("Liquid Tank") - local itemname = "techage:liquid" - if nvm.liquid and nvm.liquid.amount and nvm.liquid.amount > 0 and nvm.liquid.name then - itemname = nvm.liquid.name.." "..nvm.liquid.amount - end - return "size[5,3]".. - default.gui_bg.. - default.gui_bg_img.. - default.gui_slots.. - "box[0,-0.1;4.8,0.5;#c6e8ff]".. - "label[1.5,-0.1;"..minetest.colorize("#000000", title).."]".. - help(4.4, -0.1).. - techage.item_image(2, 1, itemname) -end - -local function fill_container(pos, inv, empty_container) - local nvm = techage.get_nvm(pos) - nvm.liquid = nvm.liquid or {} - nvm.liquid.amount = nvm.liquid.amount or 0 - local full_container = liquid.get_full_container(empty_container, nvm.liquid.name) - if empty_container and full_container then - local ldef = liquid.get_liquid_def(full_container) - if ldef and nvm.liquid.amount - ldef.size >= 0 then - if inv:room_for_item("dst", {name = full_container}) then - inv:add_item("dst", {name = full_container}) - nvm.liquid.amount = nvm.liquid.amount - ldef.size - if nvm.liquid.amount == 0 then - nvm.liquid.name = nil - end - return true - end - end - end - -- undo - inv:add_item("src", {name = empty_container}) - return false -end - -local function empty_container(pos, inv, full_container) - local nvm = techage.get_nvm(pos) - nvm.liquid = nvm.liquid or {} - nvm.liquid.amount = nvm.liquid.amount or 0 - local tank_size = LQD(pos).capa or 0 - local ldef = liquid.get_liquid_def(full_container) - print("ldef", dump(ldef), "tank_size", tank_size) - if ldef and (not nvm.liquid.name or ldef.inv_item == nvm.liquid.name) then - if nvm.liquid.amount + ldef.size <= tank_size then - if inv:room_for_item("dst", {name = ldef.container}) then - inv:add_item("dst", {name = ldef.container}) - nvm.liquid.amount = nvm.liquid.amount + ldef.size - nvm.liquid.name = ldef.inv_item - return true - end - end - end - -- undo - inv:add_item("src", {name = full_container}) - return false -end - ---function techage.liquid.move_item(pos, stack, size, formspec) --- local nvm = techage.get_nvm(pos) --- local inv = M(pos):get_inventory() --- if liquid.is_container_empty(stack:get_name()) then --- fill_container(pos, inv) --- else --- empty_container(pos, inv, size) --- end --- M(pos):set_string("formspec", formspec(pos, nvm)) ---end - -function techage.liquid.is_empty(pos) - local nvm = techage.get_nvm(pos) - local inv = minetest.get_meta(pos):get_inventory() - return inv:is_empty("src") and inv:is_empty("dst") and (not nvm.liquid or (nvm.liquid.amount or 0) == 0) -end - -techage.liquid.tubing = { --- on_pull_item = function(pos, in_dir, num) --- local inv = M(pos):get_inventory() --- if not inv:is_empty("dst") then --- local taken = techage.get_items(inv, "dst", num) --- if not inv:is_empty("src") then --- fill_container(pos, inv) --- end --- return taken --- end --- end, --- on_push_item = function(pos, in_dir, stack) --- local inv = M(pos):get_inventory() --- if inv:room_for_item("src", stack) then --- inv:add_item("src", stack) --- if liquid.is_container_empty(stack:get_name()) then --- fill_container(pos, inv) --- else --- empty_container(pos, inv) --- end --- return true --- end --- return false --- end, --- on_unpull_item = function(pos, in_dir, stack) --- local meta = M(pos) --- local inv = meta:get_inventory() --- return techage.put_items(inv, "dst", stack) --- end, - on_recv_message = function(pos, src, topic, payload) - if topic == "load" then - local nvm = techage.get_nvm(pos) - return techage.power.percent(LQD(pos).capa, (nvm.liquid and nvm.liquid.amount) or 0) - elseif topic == "size" then - return LQD(pos).capa - else - return "unsupported" - end - end, -} - - -techage.liquid.fill_container = fill_container -techage.liquid.empty_container = empty_container \ No newline at end of file diff --git a/liquids/tank.lua b/liquids/tank.lua index 05ca92e..7ae7f85 100644 --- a/liquids/tank.lua +++ b/liquids/tank.lua @@ -222,7 +222,7 @@ minetest.register_node("techage:ta4_tank", { sounds = default.node_sound_metal_defaults(), }) -techage.register_node({"techage:ta3_tank", "techage:ta4_tank", "techage:oiltank"}, liquid.tubing) +techage.register_node({"techage:ta3_tank", "techage:ta4_tank", "techage:oiltank"}, liquid.recv_message) Pipe:add_secondary_node_names({"techage:ta3_tank", "techage:ta4_tank", "techage:oiltank"}) diff --git a/manuals/manual_ta4_DE.md b/manuals/manual_ta4_DE.md index 09fde67..d449405 100644 --- a/manuals/manual_ta4_DE.md +++ b/manuals/manual_ta4_DE.md @@ -171,7 +171,7 @@ Der Generator dient zur Stromerzeugung. Daher muss auch der Generator am Stromne ### TA4 Röhre / Pipe -Die Röhren dienen bei TA4 zur Weiterleitung von Gas und Dampf. +Die Röhren dienen bei TA4 zur Weiterleitung von Gas und Flüssigkeiten. Die maximale Leitungslänge beträgt 100 m. [ta4_pipe|image] @@ -182,10 +182,10 @@ Die maximale Leitungslänge beträgt 100 m. Strom kann mittels Elektrolyse in Wasserstoff und Sauerstoff aufgespalten werden. Auf der anderen Seite kann über eine Brennstoffzelle Wasserstoff mit Sauerstoff aus der Luft wieder in Strom umgewandelt werden. Damit können Stromspitzen oder ein Überangebot an Strom in Wasserstoff umgewandelt und so gespeichert werden. -Im Spiel kann Strom mit Hilfe des Elektrolyseurs in Wasserstoff-Items und Wasserstoff-Items über die Brennstoffzelle wieder in Strom umgewandelt werden. -Damit kann Strom (in Form von Wasserstoff-Items) nicht nur in Kisten gelagert, sonder auch über Wagen (carts) oder Röhren transportiert werden. +Im Spiel kann Strom mit Hilfe des Elektrolyseurs in Wasserstoff und Wasserstoff über die Brennstoffzelle wieder in Strom umgewandelt werden. +Damit kann Strom (in Form von Wasserstoff) nicht nur in Tanks gelagert, sonder mit Hilfe von Gasflaschen auch mit Wagen (carts) transportiert werden. -Die Umwandlung von Strom in Wasserstoff und zurück ist aber verlustbehaftet. Von 100 Einheiten Strom kommen nach der Umwandlung in Wasserstoff und zurück nur 75 Einheiten Strom wieder raus. +Die Umwandlung von Strom in Wasserstoff und zurück ist aber verlustbehaftet. Von 100 Einheiten Strom kommen nach der Umwandlung in Wasserstoff und zurück nur 83 Einheiten Strom wieder raus. [ta4_hydrogen|image] @@ -193,9 +193,10 @@ Die Umwandlung von Strom in Wasserstoff und zurück ist aber verlustbehaftet. Vo ### Elektrolyseur Der Elektrolyseur wandelt Strom in Wasserstoff um. -Es muss von links mit Strom versorgt werden. Rechts können die Wasserstoff-Items per Schieber entnommen werden. +Es muss von links mit Strom versorgt werden. Rechts kann Wasserstoff über Röhren und Pumpen entnommen werden. -Der Elektrolyseur kann bis zu 40 ku an Strom aufnehmen und generiert alle 8 s ein Wasserstoff Item. +Der Elektrolyseur kann bis zu 30 ku an Strom aufnehmen und generiert dann alle 4 s ein Wasserstoff Item. +In den Elektrolyseur passen 200 Einheiten Wasserstoff. [ta4_electrolyzer|image] @@ -203,9 +204,9 @@ Der Elektrolyseur kann bis zu 40 ku an Strom aufnehmen und generiert alle 8 s ei ### Brennstoffzelle Die Brennstoffzelle wandelt Wasserstoff in Strom um. -Sie muss von links per Schieber mit Wasserstoff-Items versorgt werden. Rechts ist der Stromanschluss. +Sie muss von links per Pumpe mit Wasserstoff versorgt werden. Rechts ist der Stromanschluss. -Die Brennstoffzelle kann bis zu 40 ku an Strom abgeben und benötigt dazu alle 6 s ein Wasserstoff Item. +Die Brennstoffzelle kann bis zu 25 ku an Strom abgeben und benötigt dazu alle 4 s ein Wasserstoff Item. [ta4_fuelcell|image] diff --git a/oil/reboiler.lua b/oil/reboiler.lua index ed7f11d..28d7a76 100644 --- a/oil/reboiler.lua +++ b/oil/reboiler.lua @@ -136,7 +136,6 @@ local function after_dig_node(pos, oldnode) end local function tubelib2_on_update2(pos, outdir, tlib2, node) - print("tubelib2_on_update2", tlib2.tube_type) if tlib2.tube_type == "pipe2" then liquid.update_network(pos, outdir, tlib2) else diff --git a/ta3_power/akkubox.lua b/ta3_power/akkubox.lua index 87dbed4..8aa546a 100644 --- a/ta3_power/akkubox.lua +++ b/ta3_power/akkubox.lua @@ -37,10 +37,10 @@ local function formspec(self, pos, nvm) "box[0,-0.1;4.8,0.5;#c6e8ff]".. "label[1,-0.1;"..minetest.colorize( "#000000", S("TA3 Akku Box")).."]".. power.formspec_label_bar(0, 0.8, S("Load"), PWR_CAPA, capa).. - "image_button[3,2;1,1;".. self:get_state_button_image(nvm) ..";state_button;]".. + "image_button[2.6,2;1,1;".. self:get_state_button_image(nvm) ..";state_button;]".. "tooltip[3,2;1,1;"..self:get_state_tooltip(nvm).."]".. - "label[4.2,1.2;Flow]".. - "image[4,1.7;1,2;"..techage.power.formspec_load_bar(needed, PWR_PERF).."]" + "label[3.7,1.2;"..S("Electricity").."]".. + "image[3.8,1.7;1,2;"..techage.power.formspec_load_bar(needed, PWR_PERF).."]" end local function on_power(pos) diff --git a/ta3_power/tiny_generator.lua b/ta3_power/tiny_generator.lua index 84b1240..fbbdbdf 100644 --- a/ta3_power/tiny_generator.lua +++ b/ta3_power/tiny_generator.lua @@ -39,7 +39,7 @@ local function formspec(self, pos, nvm) "image[1.4,1.6;1,1;techage_form_arrow_bg.png^[transformR270]".. "image_button[1.4,3.2;1,1;".. self:get_state_button_image(nvm) ..";state_button;]".. "tooltip[1.5,3;1,1;"..self:get_state_tooltip(nvm).."]".. - power.formspec_label_bar(2.5, 0.8, S("power"), PWR_CAPA, nvm.provided) + power.formspec_label_bar(2.5, 0.8, S("Electricity"), PWR_CAPA, nvm.provided) end local function play_sound(pos) @@ -211,8 +211,16 @@ minetest.register_node("techage:tiny_generator", { State:node_init(pos, nvm, number) M(pos):set_string("formspec", formspec(State, pos, nvm)) M(pos):set_int("outdir", networks.side_to_outdir(pos, "R")) + Pipe:after_place_node(pos) + Cable:after_place_node(pos) end, + after_dig_node = function(pos, oldnode) + Pipe:after_dig_node(pos) + Cable:after_dig_node(pos) + techage.del_mem(pos) + end, + on_receive_fields = on_receive_fields, on_rightclick = on_rightclick, on_punch = fuel.on_punch,