Skip to content

add function to not use up all ingredients (reserve slot for item-type)#189

Open
IIIullaIII wants to merge 6 commits intomt-mods:masterfrom
IIIullaIII:master
Open

add function to not use up all ingredients (reserve slot for item-type)#189
IIIullaIII wants to merge 6 commits intomt-mods:masterfrom
IIIullaIII:master

Conversation

@IIIullaIII
Copy link
Copy Markdown

@IIIullaIII IIIullaIII commented Feb 20, 2026

Adds a button, to select whether to keep 1 item in the ingredient slot and prevent other ingredients from filling it. Defaults to off, to completely empty the slots when crafting (current behaviour).

Added a button, on to select whether to keep 1 item in the ingredient slot and prevent other ingredients from filling it, off to completely empty the slots when crafting
@The4codeblocks
Copy link
Copy Markdown
Contributor

did you mean to include the .it translation

Comment thread autocrafter.lua Outdated
end

local function autocraft(inventory, craft)
local function autocraft(inventory, craft,pos)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing space

Comment thread autocrafter.lua Outdated
if not consumption then
return false
end
-- BLOCk (Riserve 1 item)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for all-caps, parenthesis and "reserve" not "Riserve"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-- reserve 1 item is sufficient

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok sorry for mystacle i have bad english :-P and I didn't look at the comments in the file, I initially wrote them in Italian for personal use to test the mod

Comment thread autocrafter.lua Outdated

for _ = 1, math.floor(elapsed / craft_time) do
local continue = autocraft(inventory, craft)
local continue = autocraft(inventory, craft,pos)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing space

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread autocrafter.lua Outdated
-- Reserve State
local res_state = meta:get_int("reserve") == 1
local res_icon = res_state and "pipeworks_button_on.png" or "pipeworks_button_off.png"
local res_status_txt = res_state and S("RESERVE: ON") or S("RESERVE: OFF")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you feel we need all-caps status text?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not necessary, it was just for aesthetics

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread autocrafter.lua Outdated
return enabled
end


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are all these empty lines for? If I'm not mistaken, pipeworks doesn't usually use this kind of formatting. I'd rather have the deleted comments back ;)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I apologize again and yes I deleted my comments in Italian that I used for testing and maybe I deleted a few too many comments too

Comment thread autocrafter.lua Outdated
inv:set_size("recipe", 3 * 3)
inv:set_size("dst", 4 * 3)
inv:set_size("output", 1)
meta:set_int("reserve", 0)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check indentation here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread autocrafter.lua Outdated
Comment thread autocrafter.lua Outdated
@SwissalpS SwissalpS changed the title add function add function to not use up all ingredients (reserve slot for item-type) Feb 20, 2026
@SwissalpS
Copy link
Copy Markdown
Contributor

Does this work with group ingredients? e.g. mulch -> 8 group:leaves and 1 group:wood

@SwissalpS
Copy link
Copy Markdown
Contributor

For the record: I think it would be better to leave ingredient input management to players. Makes for more interesting in-game solutions than hand-holding via the mod.

@SwissalpS SwissalpS added the controversial Strongly divided opinions label Feb 20, 2026
@SwissalpS SwissalpS marked this pull request as draft February 20, 2026 21:26
@The4codeblocks
Copy link
Copy Markdown
Contributor

The4codeblocks commented Feb 20, 2026

Does this work with group ingredients? e.g. mulch -> 8 group:leaves and 1 group:wood

Is that like just leaving one of a group with no regard for which member it is?

anyway, another solution may just be rejecting inputs that go above a certain capacity quota, may just be 2 slots

@OgelGames
Copy link
Copy Markdown
Contributor

This won't help if the recipe uses a non-stackable item (e.g. a bucket of water); in that case the only way to prevent it from filling is to regulate the input, not the consumption.

@IIIullaIII
Copy link
Copy Markdown
Author

did you mean to include the .it translation
I added too it traduction and 1 button for chice if keep assignment of the ingredients in the autocraft inventory

@IIIullaIII
Copy link
Copy Markdown
Author

For the record: I think it would be better to leave ingredient input management to players. Makes for more interesting in-game solutions than hand-holding via the mod.

I made this with the possibility of choosing whether to activate it or not because in automation with input pipes for example a farm with a chainsaw that has to produce bonemeal will find itself receiving the entire inventory of the autocrafter full of leaves and wood as in the minority it does not have space it is only used for the input automations if it is not needed just have it in off so that it will use all the ingredients

@IIIullaIII IIIullaIII marked this pull request as ready for review February 22, 2026 23:00
@IIIullaIII
Copy link
Copy Markdown
Author

Does this work with group ingredients? e.g. mulch -> 8 group:leaves and 1 group:wood

yes work with group

@IIIullaIII
Copy link
Copy Markdown
Author

IIIullaIII commented Feb 22, 2026

This won't help if the recipe uses a non-stackable item (e.g. a bucket of water); in that case the only way to prevent it from filling is to regulate the input, not the consumption.

Yes, this is an error. In fact, non-stackable items are used and only 1 remain in memory, but it becomes useless. For example, if you put 10 water buckets, only 1 remains and will not be used. Generally, in recipes with buckets, a maximum of 4 are used, which, once used, are sent back to the autocraft after being filled. Instead of using this system, I would opt to remove the non-stackable items from the reserve system.

@The4codeblocks
Copy link
Copy Markdown
Contributor

The4codeblocks commented Feb 22, 2026

This won't help if the recipe uses a non-stackable item (e.g. a bucket of water); in that case the only way to prevent it from filling is to regulate the input, not the consumption.

Yes, this is an error. In fact, non-stackable items are used and only remain in memory, but it becomes useless. For example, if you put 10 water buckets, only 1 remains and will not be used. Generally, in recipes with buckets, a maximum of 4 are used, which, once used, are sent back to the autocraft after being filled. Instead of using this system, I would opt to remove the non-stackable items from the reserve system.

what they're saying is that you can run out of space for nonstackables because other items fill the space up

Code fixes and removal of non-stackable items from the reserve function
no reservation for a single element in the group but only one of them belonging to the group
@IIIullaIII
Copy link
Copy Markdown
Author

This won't help if the recipe uses a non-stackable item (e.g. a bucket of water); in that case the only way to prevent it from filling is to regulate the input, not the consumption.

Yes, this is an error. In fact, non-stackable items are used and only remain in memory, but it becomes useless. For example, if you put 10 water buckets, only 1 remains and will not be used. Generally, in recipes with buckets, a maximum of 4 are used, which, once used, are sent back to the autocraft after being filled. Instead of using this system, I would opt to remove the non-stackable items from the reserve system.

wat they're saying that you can run out of space for nonstackables because other items fill the space up

No, it's just that it's useless to keep a slot occupied if the item isn't stackable, it would only occupy that space without being able to use it, so I removed all the non-stackable ones from the reserve system.

@SwissalpS
Copy link
Copy Markdown
Contributor

This will still not work as hoped. Excluding non-stackables still allows inventory to be blocked by them.

Allowing only one per group will cause items to be rejected that are essential.
E.g. mulch: two aspen trunks arrive and 10 aspen leaves. 1 mulch is crafted leaving one aspen trunk and two aspen leaves. Now any pine needles and trunks are rejected, only aspen are allowed in.

I'm still convinced this kind of management should be left out of mod code and done by players in-game.
There they can adjust the filter to exactly what they need and not have to find out how exactly the mod
allows and rejects which items in which cases.

About style:
In [pipeworks] we are doing an effort to have new comments follow this structure:
-- First capitalized
Not --No space before first word and certainly not --ALL CAPS COMMENT
Spaces after commas and arround operators.

@IIIullaIII
Copy link
Copy Markdown
Author

This won't help if the recipe uses a non-stackable item (e.g. a bucket of water); in that case the only way to prevent it from filling is to regulate the input, not the consumption.

Yes, this is an error. In fact, non-stackable items are used and only remain in memory, but it becomes useless. For example, if you put 10 water buckets, only 1 remains and will not be used. Generally, in recipes with buckets, a maximum of 4 are used, which, once used, are sent back to the autocraft after being filled. Instead of using this system, I would opt to remove the non-stackable items from the reserve system.

wat they're saying that you can run out of space for nonstackables because other items fill the space up

No I'm saying that they are not stackable like water buckets, they are consumed even if in a craft you never use more than 3 or 4 buckets at a time to make a filling rotation but I removed the non-stackable ones in general especially because it would be useless to keep an unusable full slot I wanted to create an additional window that only assigns the slot without keeping the item, similar to that of sign bot but I noticed that even there the stackable items give problems, so no retention of irtem buchet as the crafting is slow and there are no fast automations such as creating chocolate biscuits the autocrafter fills with wheat and the cocoa does not find space as it is much less and matures in more time, or in the bonemeal farm with leaves and trunks if you cut two trees the autocrafter will be full of leaves and the trunks do not find space and many other recipes require a placeholder, if I made it it is because many people asked me for it also on my server for which I adopted another system, an intelligent distributor among the autocrafter and the injector

@IIIullaIII
Copy link
Copy Markdown
Author

IIIullaIII commented Mar 1, 2026

This will still not work as hoped. Excluding non-stackables still allows inventory to be blocked by them.

Allowing only one per group will cause items to be rejected that are essential. E.g. mulch: two aspen trunks arrive and 10 aspen leaves. 1 mulch is crafted leaving one aspen trunk and two aspen leaves. Now any pine needles and trunks are rejected, only aspen are allowed in.

I'm still convinced this kind of management should be left out of mod code and done by players in-game. There they can adjust the filter to exactly what they need and not have to find out how exactly the mod allows and rejects which items in which cases.

About style: In [pipeworks] we are doing an effort to have new comments follow this structure: -- First capitalized Not --No space before first word and certainly not --ALL CAPS COMMENT Spaces after commas and arround operators.

''This will still not work as hoped. Excluding non-stackables still allows inventory to be blocked by them.''
This is a problem that already exists in the mod, I have excluded it because it makes no sense to keep a slot full of only one element, it would mean taking away a space, and it is difficult to farm with non-stackable objects with the exception of water buckets which must be reused empty and then filled by a nodebreaker, a slow but continuous process.
2)
'' Allowing only one per group will cause items to be rejected that are essential. E.g. mulch: two aspen trunks arrive and 10 aspen leaves. 1 mulch is crafted leaving one aspen trunk and two aspen leaves. Now any pine needles and trunks are rejected, only aspen are allowed in.''
Haven't you tried the mod? Regardless of the name, it uses groups, so it will accept all types of trunks and leaves, but in that specified slot there will always be room for the preferred tree in the farm. Generally, 20 types of trees are not used, but 4 or 5. The excess of leaves in some trees is already an existing problem. The autocrafter fills up with leaves and leaves no room for trunks, and I'm talking about farms with Chinasaw. This way, however, one slot or even one per type is guaranteed. The excess is not accepted, as already happens. In fact, the problem with autocrafter is precisely that it doesn't care about the recipe, but can fill the inventory with anything, even if it's not related to the recipe.
This forces you to use a sorter tube. There are recipes that require up to 9 ingredients, and yes, you could use a lua_sorting_tube, but not everyone knows how to use it. Many younger players prefer a simpler and more intuitive system, and this system does not prevent you from learning and improving your knowledge of using lua sorting. That's why there's the button because you can disable it if you don't need it and you're a pro, but enable it if you still want to play without getting stuck and feeling incompetent.
3)
''> I'm still convinced this kind of management should be left out of mod code and done by players in-game. There they can adjust the filter to exactly what they need and not have to find out how exactly the mod allows and rejects which items in which cases.''
Instead, given the problem described in point 2, I would add a further modification, that is, that the autocrafter only accepts ingredients and groups dedicated to the recipe and not everything that flows in the pipes. In this way, you would already have an autosorter and the possibility of choosing which element to actually keep and which to reject. If you want, I can implement it.
4)
About style: In [pipeworks] we are doing an effort to have new comments follow this structure: -- First capitalized Not --No space before first word and certainly not --ALL CAPS COMMENT Spaces after commas and arround operators.

Yes you are right, I thought I had removed them all, I will check again immediately and I apologize for the oversight

-- removed First capital letter in comment and -COMMENT ALL CAPS
@IIIullaIII
Copy link
Copy Markdown
Author

Does this work with group ingredients? e.g. mulch -> 8 group:leaves and 1 group:wood

yes

@SwissalpS
Copy link
Copy Markdown
Contributor

Instead, given the problem described in point 2, I would add a further modification, that is, that the autocrafter only accepts ingredients and groups dedicated to the recipe and not everything that flows in the pipes. In this way, you would already have an autosorter and the possibility of choosing which element to actually keep and which to reject. If you want, I can implement it.

No need. All these 'problems' can be managed well in-game to suit whatever situation, tailored to what the player wants. Using luatubes, detector tubes and only injecting what is needed into the autocrafter.

If your players need a 'duplo' version, maybe consider making predefined autocrafters that e.g. only craft mulch another that only crafts canned tomatoes etc.

@SwissalpS
Copy link
Copy Markdown
Contributor

See discussions about similar ideas:
#133
#80

@IIIullaIII
Copy link
Copy Markdown
Author

See discussions about similar ideas: #133 #80

Many players want this idea but rightly the final choice is yours

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

controversial Strongly divided opinions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants