Jump to content

Issues about API AddRecipe2 and AddRecipeFilter while migrate from AddRecipe and RECIPETABS


Recommended Posts

There is a mod which is developed years ago, and old Recipe APIs were applied to the mod.

Now, I am planning to migrate this mod to the new Recipe APIs, but during the migration process, I encountered some issues.

As the follow figure:

image.png.29d974a6ed8dcf9c1ac1d632d2cd814d.png

The first Tab is created as the follow code:

GLOBAL.RECIPETABS['FHL'] = {str = "FHL", sort=10, icon = "fhltab.tex", icon_atlas = "images/inventoryimages/fhltab.xml", "fhl"}

Yes, the mod adopts the old APIs for RecipeTab, and I tried to migrate with the code:

local filter_def = {
    name = "FHLL",  
    atlas = "images/inventoryimages/fhl_cake2.xml",
    image = "fhl_cake2.tex"
}
recipeFilter = AddRecipeFilter(filter_def)

And then I invoke the AddRecipe2, it produce a cake with three logs:

AddRecipe2("fhl_cake24", {Ingredient("log", 3)}, TECH.NONE, {product="fhl_cake2", image="fhl_cake2.tex"}, {"FHLL"})

Then the code create the last Tab:

image.png.f4ed5e4f8b65d7594fa17bae8198db8a.png

However, when I select the last Tab:

image.thumb.png.03e8515cdadf80a8c1ffbb16330bbc7e.png

The figures may be obscure, but try to understand.

My question is, what caused this issue, image? filter? or others?

Besides, I tried to default the filter, and when I select the Mod Item(the red arrow), the recipe can be found:

image.thumb.png.6674c75aa90fac8e795e09aaf0ebe67b.png

As you seen in the figure, (the blue arrow) the recipe lose its image. But I really have set the image of the recipe.

So what should I take into account?

Link to comment
Share on other sites

15 hours ago, ariadnesGambit said:

After a cursory look through the code, it looks like you need to set a string for your filter. Just adding this to modmain should do the trick:

GLOBAL.STRINGS.UI.CRAFTING_FILTERS.FHLL = "FHLL" -- Change this to whatever you want!

 

It is amazing, you are right. Thanks a lot.

  • GL Happy 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...