From 5fec894a114c003d7ff4bafb1637be34387cb533 Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Mon, 6 Jul 2020 19:13:37 +0200 Subject: [PATCH] cracking and hydrogenation recipes added --- basis/lib.lua | 15 +++++++++++++++ basis/recipe_lib.lua | 5 ++++- chemistry/ta4_doser.lua | 31 +++++++++++++++++++++++++++---- chemistry/ta4_reactor.lua | 9 +++++++++ doc/manual_DE.lua | 9 ++++++++- doc/manual_EN.lua | 11 +++++++++-- init.lua | 1 + items/powder.lua | 8 +++++++- locale/techage.de.tr | 9 +++++++++ locale/template.txt | 9 +++++++++ manuals/manual_ta4_DE.md | 8 +++++++- manuals/manual_ta4_EN.md | 11 +++++++++-- 12 files changed, 114 insertions(+), 12 deletions(-) diff --git a/basis/lib.lua b/basis/lib.lua index a87ab61..1493fa6 100644 --- a/basis/lib.lua +++ b/basis/lib.lua @@ -226,6 +226,21 @@ function techage.item_image(x, y, itemname) label end +function techage.item_image_small(x, y, itemname, tooltip_prefix) + local name = unpack(string.split(itemname, " ")) + local tooltip = "" + local ndef = minetest.registered_nodes[name] or minetest.registered_items[name] or minetest.registered_craftitems[name] + + if ndef and ndef.description then + local text = minetest.formspec_escape(ndef.description) + tooltip = "tooltip["..x..","..y..";0.8,0.8;"..tooltip_prefix..": "..text..";#0C3D32;#FFFFFF]" + end + + return "box["..x..","..y..";0.65,0.7;#808080]".. + "item_image["..x..","..y..";0.8,0.8;"..name.."]".. + tooltip +end + function techage.mydump(o, indent, nested, level) local t = type(o) if not level and t == "userdata" then diff --git a/basis/recipe_lib.lua b/basis/recipe_lib.lua index 35bbbae..bee3fa8 100644 --- a/basis/recipe_lib.lua +++ b/basis/recipe_lib.lua @@ -83,6 +83,7 @@ function techage.recipes.add(rtype, recipe) item.waste = {name = name or "", num = tonumber(num) or 0} name, num = unpack(string.split(recipe.output, " ")) item.output = {name = name or "", num = tonumber(num) or 0} + item.catalyst = recipe.catalyst Recipes[rtype][name] = item RecipeList[rtype][#(RecipeList[rtype])+1] = name @@ -103,10 +104,12 @@ function techage.recipes.formspec(x, y, rtype, nvm) local recipe = recipes[recipe_list[idx]] or RECIPE local output = recipe.output.name.." "..recipe.output.num local waste = recipe.waste.name.." "..recipe.waste.num + local catalyst = recipe.catalyst and techage.item_image_small(2.05, 0, recipe.catalyst, S("Catalyst")) or "" return "container["..x..","..y.."]".. "background[0,0;4,3;techage_form_grey.png]".. input_string(recipe).. - "image[2,0.5;1,1;techage_form_arrow.png]".. + "image[2,0.7;1,1;techage_form_arrow.png]".. + catalyst.. techage.item_image(2.95, 0, output).. techage.item_image(2.95, 1, waste).. "button[0,2;1,1;priv;<<]".. diff --git a/chemistry/ta4_doser.lua b/chemistry/ta4_doser.lua index a94eae8..dfbeff7 100644 --- a/chemistry/ta4_doser.lua +++ b/chemistry/ta4_doser.lua @@ -117,6 +117,16 @@ local function can_start(pos, nvm, state) if not res then return S("reactor defect or no power") end + local recipe = recipes.get(nvm, "ta4_doser") + if recipe.catalyst then + res = reactor_cmnd(pos, "catalyst") + if not res or res == "" then + return S("catalyst missing") + end + if res ~= recipe.catalyst then + return S("wrong catalyst") + end + end return true end @@ -154,6 +164,10 @@ local function dosing(pos, nvm, elapsed) State:idle(pos, nvm) return end + -- available liquids + local liquids = get_liquids(pos) + local recipe = recipes.get(nvm, "ta4_doser") + if not liquids or not recipe then return end -- check from time to time nvm.check_cnt = (nvm.check_cnt or 0) + 1 if nvm.check_cnt >= 4 then @@ -164,11 +178,20 @@ local function dosing(pos, nvm, elapsed) reactor_cmnd(pos, "stop") return end + if recipe.catalyst then + res = reactor_cmnd(pos, "catalyst") + if not res then + State:fault(pos, nvm, S("catalyst missing")) + reactor_cmnd(pos, "stop") + return + end + if res ~= recipe.catalyst then + State:fault(pos, nvm, S("wrong catalyst")) + reactor_cmnd(pos, "stop") + return + end + end end - -- available liquids - local liquids = get_liquids(pos) - local recipe = recipes.get(nvm, "ta4_doser") - if not liquids or not recipe then return end -- inputs local starter = get_starter_name(pos) for _,item in pairs(recipe.input) do diff --git a/chemistry/ta4_reactor.lua b/chemistry/ta4_reactor.lua index bfce7ae..ee8e3b2 100644 --- a/chemistry/ta4_reactor.lua +++ b/chemistry/ta4_reactor.lua @@ -102,6 +102,14 @@ techage.register_node({"techage:ta4_reactor_fillerpipe"}, { return true elseif topic == "waste" then return base_waste(pos, payload or {}) + elseif topic == "catalyst" then + local pos2,node = Pipe:get_node(pos, 5) + if not node or node.name ~= "techage:ta4_reactor" then + return + end + local inv = M(pos2):get_inventory() + local stack = inv:get_stack("main", 1) + return stack and stack:get_name() else return stand_cmnd(pos, topic, payload or {}) end @@ -116,6 +124,7 @@ local function formspec() default.gui_slots.. "box[0,-0.1;7.8,0.5;#c6e8ff]".. "label[3,-0.1;"..minetest.colorize("#000000", title).."]".. + "label[4.5,1.2;"..S("Catalyst").."]".. "list[context;main;3.5,1;1,1;]".. "list[current_player;main;0,2.3;8,4;]".. "listring[context;main]".. diff --git a/doc/manual_DE.lua b/doc/manual_DE.lua index aeb9a73..f75596e 100644 --- a/doc/manual_DE.lua +++ b/doc/manual_DE.lua @@ -1233,6 +1233,12 @@ techage.manual_DE.aText = { "\n".. "Hinweis 2: Tanks oder Silos mit verschiedenen Inhalten dürfen nicht zu einem Leitungssystem verbunden werden. Mehrere Tanks oder Silos mit gleichem Inhalt dürfen dagegen parallel an einer Leitung hängen.\n".. "\n".. + "Beim Cracken werden lange Kette von Kohlenwasserstoffen unter Verwendung eines Katalysator in kurze Ketten gebrochen.\n".. + "Als Katalysator dient Gibbsitpulver (wird nicht verbraucht). Damit kann Bitumen in Schweröl\\, Schweröl in Naphtha und Naphtha in Benzin umgewandelt werden.\n".. + "\n".. + "Bei der Hydrierung werden einem Molekül Paare von Wasserstoffatomen hinzugefügt\\, um kurzkettige Kohlenwasserstoffe in lange umzuwandeln. Hier wird Eisenpulver als Katalysator benötigt (wird nicht verbraucht). Damit kann Benzin in Naphtha\\, \n".. + "Naphtha in Schweröl und Schweröl in Bitumen umgewandelt werden.\n".. + "\n".. "\n".. "\n", "Teil des Chemischen Reaktors.\n".. @@ -1249,7 +1255,8 @@ techage.manual_DE.aText = { "\n".. "\n".. "\n", - "Teil des Chemischen Reaktors.\n".. + "Teil des Chemischen Reaktors. Der Reaktor verfügt über ein Inventar für die Katalysator \n".. + "Gegenstände (für Cracking- und Hydrierungs-Rezepte).\n".. "\n".. "\n".. "\n", diff --git a/doc/manual_EN.lua b/doc/manual_EN.lua index 7786168..9e50a8b 100644 --- a/doc/manual_EN.lua +++ b/doc/manual_EN.lua @@ -1224,6 +1224,13 @@ techage.manual_EN.aText = { "\n".. "Note 2: Tanks or silos with different contents must not be connected to a pipe system. In contrast\\, several tanks or silos with the same content may hang in parallel on one line.\n".. "\n".. + "Cracking breaks long chains of hydrocarbons into short chains using a catalyst.\n".. + "Gibbsite powder serves as a catalyst (is not consumed). It can be used to convert bitumen into fueloil\\, fueloil into naphtha and naphtha into gasoline.\n".. + "\n".. + "In hydrogenation\\, pairs of hydrogen atoms are added to a molecule to convert short-chain hydrocarbons into long ones. \n".. + "Here iron powder is required as a catalyst (is not consumed). It can be used to convert gasoline into naphtha\\,\n".. + "naphtha into fueloil\\, and fueloil into bitumen.\n".. + "\n".. "\n".. "\n", "Part of the chemical reactor.\n".. @@ -1234,13 +1241,13 @@ techage.manual_EN.aText = { "As with other machines:\n".. "\n".. " - if the doser is in standby mode\\, one or more ingredients are missing\n".. - " - if thedoser is in the blocked state\\, the outlet tank or silo is full\\, defective or incorrectly connected\n".. + " - if the doser is in the blocked state\\, the outlet tank or silo is full\\, defective or incorrectly connected\n".. "\n".. "The doser does not need any electricity. A recipe is processed every 10 s.\n".. "\n".. "\n".. "\n", - "Part of the chemical reactor.\n".. + "Part of the chemical reactor. The reactor has a inventory for the catalyst items (for cracking and hydrogenation recipes).\n".. "\n".. "\n".. "\n", diff --git a/init.lua b/init.lua index d603588..ff16bea 100644 --- a/init.lua +++ b/init.lua @@ -300,6 +300,7 @@ dofile(MP.."/items/hydrogen.lua") dofile(MP.."/items/electronic.lua") dofile(MP.."/items/redstone.lua") dofile(MP.."/items/cement.lua") +dofile(MP.."/items/cracking.lua") if techage.basalt_stone_enabled then dofile(MP.."/items/basalt.lua") diff --git a/items/powder.lua b/items/powder.lua index 872ea31..ba3a4c0 100644 --- a/items/powder.lua +++ b/items/powder.lua @@ -26,6 +26,12 @@ minetest.register_craftitem("techage:needle_powder", { groups = {powder = 1}, }) +minetest.register_craftitem("techage:iron_powder", { + description = S("Iron Powder"), + inventory_image = "techage_powder_inv.png^[colorize:#c7643d:160", + groups = {powder = 1}, +}) + techage.add_grinder_recipe({input="default:acacia_bush_leaves", output="techage:leave_powder"}) techage.add_grinder_recipe({input="default:acacia_leaves", output="techage:leave_powder"}) techage.add_grinder_recipe({input="default:aspen_leaves", output="techage:leave_powder"}) @@ -33,6 +39,6 @@ techage.add_grinder_recipe({input="default:blueberry_bush_leaves", output="techa techage.add_grinder_recipe({input="default:bush_leaves", output="techage:leave_powder"}) techage.add_grinder_recipe({input="default:jungleleaves", output="techage:leave_powder"}) techage.add_grinder_recipe({input="default:leaves", output="techage:leave_powder"}) - techage.add_grinder_recipe({input="default:pine_needles", output="techage:needle_powder"}) +techage.add_grinder_recipe({input="default:iron_lump", output="techage:iron_powder"}) diff --git a/locale/techage.de.tr b/locale/techage.de.tr index 61e3e20..2258d67 100644 --- a/locale/techage.de.tr +++ b/locale/techage.de.tr @@ -32,6 +32,9 @@ Bauxite Stone=Bauxit Biome=Biom Block configured items for open ports=Blockiere konfigurierte Gegenstände für offene Ausgänge Build derrick=Errichte Ölturm +Catalyst=Katalysator +Cement Block=Zement Block +Cement Powder=Zement Pulver Compressed Gravel=Komprimiertes Kies Configure up to 8 items @nto be pushed by the injector=Konfiguriere bis zu 8 Gegenstände \n die vom Injektor weitergegeben werden sollen Consum. 1=Konsum. 1 @@ -89,6 +92,7 @@ Insert door/gate block number(s)=Gebe Tür-/Tornummer(n) ein Intake=Stromaufnahme Inventory,Configuration=Inventar,Konfiguration Inverter=Wechselrichter +Iron Powder=Eisen Pulver Leave Powder=Laub Pulver Liquid Filler=Einfülltrichter Liquid Sampler=Flüssigkeitensammler @@ -203,6 +207,7 @@ TA Power Switch Box=TA Stromschalterbox TA Power Switch Small=TA Stromschalter klein TA Street Lamp=TA Straßenlampe TA Tank Cart=TA Tankwagen +TA Valve=TA Ventil TA1 Bronze Hammer (smash stone to gravel)=TA1 Bronzehammer (zerschlage Stein zu Kies) TA1 Burning=TA1 Brennen TA1 Charcoal=TA1 Holzkohle @@ -291,6 +296,8 @@ TA3 Timer=TA3 Timer TA3 Tiny Power Generator=TA3 Kleiner Stromgenerator TA3 Turbine=TA3 Turbine TA3 Vacuum Tube=TA3 Vakuumröhre +TA3 Valve closed=TA3 Ventil zu +TA3 Valve open=TA3 Ventil offen TA4 8x2000 Chest=TA4 8x2000 Kiste TA4 Button/Switch=TA4 Schalter/Taster TA4 Carbon Fiber=TA4 Kohlefaser @@ -404,6 +411,7 @@ added=hinzugefügt wird added or removed=hinzugefügt oder entfernt wird area is protected=Bereich ist geschützt blocking mode=Blockiert +catalyst missing=Katalysator fehlt commands like: help=Kommandos wie: help connected with=verbunden mit depth=Tiefe @@ -436,5 +444,6 @@ right to left=von rechts nach links stopped=gestoppt storage empty?=Speicher leer? water temperature=Wassertemperatur +wrong catalyst=falscher Katalysator wrong storage diameter=Falscher Wärmespeicher-Durchmesser ##### not used anymore ##### diff --git a/locale/template.txt b/locale/template.txt index 926d96b..44d7739 100644 --- a/locale/template.txt +++ b/locale/template.txt @@ -30,6 +30,9 @@ Bauxite Stone= Biome= Block configured items for open ports= Build derrick= +Catalyst= +Cement Block= +Cement Powder= Compressed Gravel= Configure up to 8 items @nto be pushed by the injector= Consum. 1= @@ -87,6 +90,7 @@ Insert door/gate block number(s)= Intake= Inventory,Configuration= Inverter= +Iron Powder= Leave Powder= Liquid Filler= Liquid Sampler= @@ -201,6 +205,7 @@ TA Power Switch Box= TA Power Switch Small= TA Street Lamp= TA Tank Cart= +TA Valve= TA1 Bronze Hammer (smash stone to gravel)= TA1 Burning= TA1 Charcoal= @@ -289,6 +294,8 @@ TA3 Timer= TA3 Tiny Power Generator= TA3 Turbine= TA3 Vacuum Tube= +TA3 Valve closed= +TA3 Valve open= TA4 8x2000 Chest= TA4 Button/Switch= TA4 Carbon Fiber= @@ -402,6 +409,7 @@ added= added or removed= area is protected= blocking mode= +catalyst missing= commands like: help= connected with= depth= @@ -434,4 +442,5 @@ right to left= stopped= storage empty?= water temperature= +wrong catalyst= wrong storage diameter= \ No newline at end of file diff --git a/manuals/manual_ta4_DE.md b/manuals/manual_ta4_DE.md index 39ad7db..4807bbc 100644 --- a/manuals/manual_ta4_DE.md +++ b/manuals/manual_ta4_DE.md @@ -237,6 +237,11 @@ Hinweis 1: Flüssigkeiten werden nur in Tanks gelagert, Stoffe in Pulverform nur Hinweis 2: Tanks oder Silos mit verschiedenen Inhalten dürfen nicht zu einem Leitungssystem verbunden werden. Mehrere Tanks oder Silos mit gleichem Inhalt dürfen dagegen parallel an einer Leitung hängen. +Beim Cracken werden lange Kette von Kohlenwasserstoffen unter Verwendung eines Katalysator in kurze Ketten gebrochen. +Als Katalysator dient Gibbsitpulver (wird nicht verbraucht). Damit kann Bitumen in Schweröl, Schweröl in Naphtha und Naphtha in Benzin umgewandelt werden. + +Bei der Hydrierung werden einem Molekül Paare von Wasserstoffatomen hinzugefügt, um kurzkettige Kohlenwasserstoffe in lange umzuwandeln. Hier wird Eisenpulver als Katalysator benötigt (wird nicht verbraucht). Damit kann Benzin in Naphtha, +Naphtha in Schweröl und Schweröl in Bitumen umgewandelt werden. [ta4_reactor|plan] @@ -258,7 +263,8 @@ Der Dosierer benötigt keinen Strom. Alle 10 s wird ein Rezept abgearbeitet. ### TA4 Reaktor / reactor -Teil des Chemischen Reaktors. +Teil des Chemischen Reaktors. Der Reaktor verfügt über ein Inventar für die Katalysator +Gegenstände (für Cracking- und Hydrierungs-Rezepte). [ta4_reactor|image] diff --git a/manuals/manual_ta4_EN.md b/manuals/manual_ta4_EN.md index 8247146..04acecd 100644 --- a/manuals/manual_ta4_EN.md +++ b/manuals/manual_ta4_EN.md @@ -238,6 +238,13 @@ Note 1: Liquids are only stored in tanks, substances in powder form only in silo Note 2: Tanks or silos with different contents must not be connected to a pipe system. In contrast, several tanks or silos with the same content may hang in parallel on one line. +Cracking breaks long chains of hydrocarbons into short chains using a catalyst. +Gibbsite powder serves as a catalyst (is not consumed). It can be used to convert bitumen into fueloil, fueloil into naphtha and naphtha into gasoline. + +In hydrogenation, pairs of hydrogen atoms are added to a molecule to convert short-chain hydrocarbons into long ones. +Here iron powder is required as a catalyst (is not consumed). It can be used to convert gasoline into naphtha, +naphtha into fueloil, and fueloil into bitumen. + [ta4_reactor|plan] @@ -251,7 +258,7 @@ The recipe can be set and the reactor started via the doser. As with other machines: - if the doser is in standby mode, one or more ingredients are missing -- if thedoser is in the blocked state, the outlet tank or silo is full, defective or incorrectly connected +- if the doser is in the blocked state, the outlet tank or silo is full, defective or incorrectly connected The doser does not need any electricity. A recipe is processed every 10 s. @@ -259,7 +266,7 @@ The doser does not need any electricity. A recipe is processed every 10 s. ### TA4 Reactor -Part of the chemical reactor. +Part of the chemical reactor. The reactor has a inventory for the catalyst items (for cracking and hydrogenation recipes). [ta4_reactor|image]