Jump to content

Crafting Recipes Filter


Recommended Posts

Hello all!

I have a question about new crafting system, because as much as I personally like it for now I don't know if there's any easy way to add specific filter tag to items/structures added with mods.

For example if it would be possible to add "tool" tag to scythe or "structure" tag to craftable catcoon den etc.

 

I created kinda big mod for myself where there's plenty of items/structures and I don't feel good with having all the recipes only in "all" and "modded" filers so If there's a way to easily add tags to their codes I would really like to know it. 

Link to comment
Share on other sites

  

On 3/24/2022 at 9:34 AM, ScottHansen said:

Notes for Modders:

  • Deprecated Functions
    • Recipe
    • AddRecipe
    • AddRecipeTab
  • New Functions
    • AddRecipe2(name, ingredients, tech, config, filters)
      • Adds a recipe to the mods filter (or to the crafting station filter if config.nounlock is true) and any other passed in filters
    • AddCharacterRecipe(name, ingredients, tech, config, extra_filters)
      • Adds a recipe to the character filter and any other passed in filters
      • config.builder_tag must be passed in
    • AddDeconstructRecipe(name, return_ingredients)
      • Adds a recipe that will not show up under any filters. These are to support the Deconstruction Staff or hammering of items that are not craftable.
    • AddRecipeToFilter(recipe_name, filter_name)
      • Adds a recipe to the end of a filter group.
    • RemoveRecipeFromFilter(recipe_name, filter_name)
      • Removes a recipe form a filter group
    • AddPrototyperDef(prototyper_prefab, data) 
      • Customizes how the research or crafting station will display in the crafting menu
      • Parameters:
        • prototyper_prefab - prefab of the station’s object
        • icon_atlas, icon_image - the icon to show on the open button and filter
        • action_str - string to display for the “build” button
        • is_crafting_station - true = you must remain at the station for each build and opens the crafting menu to the Crafting Station filter.
        • filter_text - mouse over name on the crafting station’s filter
  • Fixed TrueScrollList:ScrollToDataIndex to properly take the number of items wide into account. Added TrueScrollList:ScrollToScrollPos for people who need the previous functionality, where the passed in value is the row to scroll to.

You want to AddRecipeToFilter for existing items or use the new AddRecipe2 which contains the filters parameter a list of filters look at the recipes_filter.lua file

  • Like 1
Link to comment
Share on other sites

I don't understand what is the difference. I just wondered if there was some kind of extension to normally used code.

Example:

AddRecipe("turf_lawn", {Ingredient("cutgrass", 2), Ingredient("nitre", 1)},
RECIPETABS.TURFCRAFTING, TECH.TURFCRAFTING_ONE, nil, nil, nil, 4, nil, "images/inventoryimages/turfimg.xml", "turf_lawn.tex")

Expected upgraded code example:

AddRecipe("turf_lawn", {Ingredient("cutgrass", 2), Ingredient("nitre", 1)},
RECIPETABS.TURFCRAFTING, RECIPEFILTER.DECOR, TECH.TURFCRAFTING_ONE, nil, nil, nil, 4, nil, "images/inventoryimages/turfimg.xml", "turf_lawn.tex")

That's just my expectation, but if there's another way to add filters to recipes then I would like to know how.

 

EDIT: 

Nevermind. I now understand what's the difference. I can do it by:

AddRecipeToFilter("turf_lawn", DECOR)

or

AddRecipe2("turf_lawn", {Ingredient("cutgrass", 2), Ingredient("nitre", 1)}, RECIPETABS.TURFCRAFTING, TECH.TURFCRAFTING_ONE, nil, nil, nil, 4, nil, "images/inventoryimages/turfimg.xml", "turf_lawn.tex"), CRAFTING_FILTERS.DECOR)

 

I'm not sure if I'm using the new code properly so first method sounds safer to use.

 

Edited by Prajdo
Link to comment
Share on other sites

4 minutes ago, Prajdo said:

AddRecipe("turf_lawn", {Ingredient("cutgrass", 2), Ingredient("nitre", 1)},
RECIPETABS.TURFCRAFTING, RECIPEFILTER.DECOR, TECH.TURFCRAFTING_ONE, nil, nil, nil, 4, nil, "images/inventoryimages/turfimg.xml", "turf_lawn.tex")

That's just my expectation, but if there's another way to add filters to recipes then I would like to know how.

Tabs no longer exist and filters need to be sent in a table. Also, any extra data, like amount, atlas or image is sent differently now. Let's look at the AddRecipes2 function that IronHunter shared from a Klei post:

11 hours ago, IronHunter said:

AddRecipe2(name, ingredients, tech, config, filters)

First two arguments are the same as usual, name and ingredients. Next one is tech instead of tab, because tabs no longer exist. Then config is a table for any kind of data that before this update you used to send as extra arguments after everything else, like 4 for the amount or the atlas and image paths. Finally, we have filters, which need to be sent in a table too.

Let me give you an example of how your recipe needs to be written:

AddRecipe2("turf_lawn", {Ingredient("cutgrass",2), Ingredient("nitre", 1)}, TECH.TURFCRAFTING_ONE, {numtogive = 4, atlas = "images/inventoryimages/turfimg.xml", image = "turf_lawn.tex" }, {"DECOR"})

If you have more questions, feel free to quote me or @ me!

  • Thanks 1
  • Potato Cup 1
Link to comment
Share on other sites

Thanks! I think I finally understand how it now works but I still have one question.

Is it possible to add more then one filter to AddRecipe2 code or for adding another one it is necessary to use AddRecipeToFilter additionally?

Link to comment
Share on other sites

56 minutes ago, Prajdo said:

Thanks! I think I finally understand how it now works but I still have one question.

Is it possible to add more then one filter to AddRecipe2 code or for adding another one it is necessary to use AddRecipeToFilter additionally?

It's totally possible, just add to the filter table. Right now it's just {"DECOR"}, but you can do {"DECOR", "TOOLS", "LIGHT", "WINTER"} etc.

Just make sure to space them with a comma inbetween like I did in the example.

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...