summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFedja Beader <fedja@protonmail.ch>2020-07-23 01:49:37 +0200
committerFedja Beader <fedja@protonmail.ch>2020-07-23 01:49:37 +0200
commit505fc7cc49dcdf6195c7435ed3d989cc09953206 (patch)
treed3cb0ea7b35706532f2e0b3d29a8bc67e46711bd
parentcb58a646cfbb4f6dadb5bd17db4f63ef889d85a8 (diff)
downloadpipeworks-505fc7cc49dcdf6195c7435ed3d989cc09953206.tar
pipeworks-505fc7cc49dcdf6195c7435ed3d989cc09953206.tar.gz
pipeworks-505fc7cc49dcdf6195c7435ed3d989cc09953206.tar.bz2
pipeworks-505fc7cc49dcdf6195c7435ed3d989cc09953206.tar.xz
pipeworks-505fc7cc49dcdf6195c7435ed3d989cc09953206.zip
Add "get_recipe" digiline command for querying the current autocrafter recipe.
Useful for having the player teach the luacontroller how to craft various items.
-rw-r--r--autocrafter.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/autocrafter.lua b/autocrafter.lua
index db23a14..825b248 100644
--- a/autocrafter.lua
+++ b/autocrafter.lua
@@ -389,6 +389,27 @@ minetest.register_node("pipeworks:autocrafter", {
end
end
after_recipe_change(pos,inv)
+ elseif msg == "get_recipe" then
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ local recipe = {}
+ for y=0,2,1 do
+ local row = {}
+ for x=1,3,1 do
+ local slot = y*3+x
+ table.insert(row, inv:get_stack("recipe",slot):get_name())
+ end
+ table.insert(recipe, row)
+ end
+ local setchan = meta:get_string("channel")
+ local output = inv:get_stack("output", 1)
+ digiline:receptor_send(pos, digiline.rules.default, setchan, {
+ recipe = recipe,
+ result = {
+ name = output:get_name(),
+ count = output:get_count(),
+ }
+ })
elseif msg == "off" then
update_meta(meta, false)
minetest.get_node_timer(pos):stop()