diff options
author | Tim <t4im@users.noreply.github.com> | 2015-01-30 21:09:43 +0100 |
---|---|---|
committer | Tim <t4im@users.noreply.github.com> | 2015-01-30 21:09:43 +0100 |
commit | f79956c0b687a96254084e34d91487a69cf3485e (patch) | |
tree | aa937cc42a9e4fe5a6636d69a2c90533d8005a1b | |
parent | 51c5b63ee7e3cd951a35fafca6e12a8129855909 (diff) | |
download | pipeworks-f79956c0b687a96254084e34d91487a69cf3485e.tar pipeworks-f79956c0b687a96254084e34d91487a69cf3485e.tar.gz pipeworks-f79956c0b687a96254084e34d91487a69cf3485e.tar.bz2 pipeworks-f79956c0b687a96254084e34d91487a69cf3485e.tar.xz pipeworks-f79956c0b687a96254084e34d91487a69cf3485e.zip |
improve handling of shapeless recipes in the autocrafter recipe filling function
-rw-r--r-- | autocrafter.lua | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/autocrafter.lua b/autocrafter.lua index d374fe9..89559ba 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -151,7 +151,17 @@ local function on_output_change(pos, inventory, stack) else local input = minetest.get_craft_recipe(stack:get_name()) if not input.items or input.type ~= "normal" then return end - inventory:set_list("recipe", normalize(input.items)) + local items, width = normalize(input.items), input.width + local item_idx, width_idx = 1, 1 + for i = 1, 9 do + if width_idx <= width then + inventory:set_stack("recipe", i, items[item_idx]) + item_idx = item_idx + 1 + else + inventory:set_stack("recipe", i, ItemStack("")) + end + width_idx = (width_idx < 3) and (width_idx + 1) or 1 + end -- we'll set the output slot in after_recipe_change to the actual result of the new recipe end after_recipe_change(pos, inventory) |