Is anyone aware of using the native crafting recipe format, for defining a recipe ingredient whose group membership excludes a named group?
Most recipes that use, say, "group:stick" don't care about the other attributes. But let's say I want "group:stick,!group:purple," or that is to say, an item of group stick, but an item that is not of group purple.
Is that feasible, possible, or documented or demonstrated somewhere that I've missed?
I realize I could write a custom formspec/node that could perform this check, but I was hoping to use the native crafting recipe design.
Crafting recipe whose ingredient is not in a named group
Crafting recipe whose ingredient is not in a named group
cdb_5ea39b4225fd
-
Josselin2
- Member
- Posts: 149
- Joined: Thu May 28, 2020 15:32
- GitHub: axcore
- In-game: Josselin
- Location: Tunnelers' Abyss
Re: Crafting recipe whose ingredient is not in a named group
I don't know if there's a simpler way, but you could override the definition of every craftitem that has group:stick but not group:purple, giving it a new group, group:stick_not_purple. Then just use group:stick_not_purple in your craft recipe.
- Blockhead
- Moderator
- Posts: 2991
- Joined: Wed Jul 17, 2019 10:14
- GitHub: Montandalar
- IRC: Blockhead256
- In-game: Blockhead Blockhead256
- Location: Land Down Under
- Contact:
Re: Crafting recipe whose ingredient is not in a named group
This is not a feature of the engine, so you'll need to add it with Lua in some way. Also not guaranteed is that it looks good inside of crafting guides like that of Unified Inventory.
There's Josselin2's suggestion, which needs on_mods_loaded callbacks, which I am usually not in favour of, but if you isolate it to just applying this, then it's acceptable I suppose. But then, that sounds like pushing the problem across to C++ (which may still be fast), since then the engine has a very long list of items to check for that group. Maybe it uses an efficient data structure - I'm not sure.
The other way is on_craft / on_craft_predict. That way you keep the engine's recipe functionality, but hook into it. You can still use the native crafting grid. You scan the groups of each of the input items. This would slow all crafting down though, I think. Also, not sure it would work with e.g. pipeworks' autocrafters. Those depend on get_craft_result.
So there are some options, at least.
There's Josselin2's suggestion, which needs on_mods_loaded callbacks, which I am usually not in favour of, but if you isolate it to just applying this, then it's acceptable I suppose. But then, that sounds like pushing the problem across to C++ (which may still be fast), since then the engine has a very long list of items to check for that group. Maybe it uses an efficient data structure - I'm not sure.
The other way is on_craft / on_craft_predict. That way you keep the engine's recipe functionality, but hook into it. You can still use the native crafting grid. You scan the groups of each of the input items. This would slow all crafting down though, I think. Also, not sure it would work with e.g. pipeworks' autocrafters. Those depend on get_craft_result.
So there are some options, at least.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂
Who is online
Users browsing this forum: No registered users and 1 guest