From c57724dbd0793ad64dca3cea084c684e645c6e3f Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Sun, 11 Sep 2022 14:32:59 +0200 Subject: [PATCH] Add command to ta4_doser to change recipe, add pusher/hopper support for ta4_reactor inventory --- basis/recipe_lib.lua | 8 ++++++++ chemistry/ta4_doser.lua | 7 ++++++- chemistry/ta4_reactor.lua | 22 ++++++++++++++++++++++ iron_age/hopper.lua | 2 +- 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/basis/recipe_lib.lua b/basis/recipe_lib.lua index 4d98ee7..e583c71 100644 --- a/basis/recipe_lib.lua +++ b/basis/recipe_lib.lua @@ -169,6 +169,14 @@ function techage.recipes.get_recipe(name) return NormalizedRecipes[name] end +function techage.recipes.set_recipe(pos, rtype, idx) + local nvm = techage.get_nvm(pos) + if not nvm.running then + local recipes = Recipes[rtype] or {} + idx = tonumber(idx) or 1 + nvm.recipe_idx = range(idx, 1, #recipes) + end +end function techage.recipes.get_default_group_item_name(item_name) if item_name and item_name:sub(1, 6) == "group:" then diff --git a/chemistry/ta4_doser.lua b/chemistry/ta4_doser.lua index 316a3c6..ca99fb9 100644 --- a/chemistry/ta4_doser.lua +++ b/chemistry/ta4_doser.lua @@ -358,7 +358,12 @@ liquid.register_nodes({"techage:ta4_doser", "techage:ta4_doser_on"}, Pipe, "pump techage.register_node({"techage:ta4_doser", "techage:ta4_doser_on"}, { on_recv_message = function(pos, src, topic, payload) - return State:on_receive_message(pos, topic, payload) + if topic == "recipe" then + techage.recipes.set_recipe(pos, "ta4_doser", payload) + return true + else + return State:on_receive_message(pos, topic, payload) + end end, on_beduino_receive_cmnd = function(pos, src, topic, payload) return State:on_beduino_receive_cmnd(pos, topic, payload) diff --git a/chemistry/ta4_reactor.lua b/chemistry/ta4_reactor.lua index 2736091..6b2108d 100644 --- a/chemistry/ta4_reactor.lua +++ b/chemistry/ta4_reactor.lua @@ -168,6 +168,28 @@ minetest.register_node("techage:ta4_reactor", { sounds = default.node_sound_metal_defaults(), }) +techage.register_node({"techage:ta4_reactor"}, { + on_inv_request = function(pos, in_dir, access_type) + local meta = minetest.get_meta(pos) + return meta:get_inventory(), "main" + end, + on_pull_item = function(pos, in_dir, num, item_name) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return techage.get_items(pos, inv, "main", num) + end, + on_push_item = function(pos, in_dir, stack) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return techage.put_items(inv, "main", stack) + end, + on_unpull_item = function(pos, in_dir, stack) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return techage.put_items(inv, "main", stack) + end, +}) + minetest.register_craft({ output = 'techage:ta4_reactor', recipe = { diff --git a/iron_age/hopper.lua b/iron_age/hopper.lua index c70ac3e..745b301 100644 --- a/iron_age/hopper.lua +++ b/iron_age/hopper.lua @@ -22,7 +22,7 @@ minetest.register_alias("techage:hopper_ta1", "minecart:hopper") minecart.register_inventory( { "techage:chest_ta2", "techage:chest_ta3", "techage:chest_ta4", - "techage:meltingpot", "techage:meltingpot_active", + "techage:meltingpot", "techage:meltingpot_active", "techage:ta4_reactor", }, { put = {