Jump to content

How do I make my Ingredient a Character Ingredient?


Recommended Posts

Hi modders,

I've made a custom component which tracks collectables my character collects. These collectables are stored within the component itself rather than as an item, so to use them for crafting I figured I would need to make the ingredient a character ingredient, so it can interface with the component instead of looking for an item.

I've written all the supporting code to make this work, but I can't get my ingredient to be considered a Character Ingredient by the game unless I manually add it to the constants.lua file. Any ideas on how to get this to work?

Screenshot from my modified constants.lua
image.png.1481dae7ef79327902d9a45c9696cfdf.png

 

I tried just adding the PON entry to the GLOBAL.CHARACTER_INGREDIENT table from my modmain.lua, but it seems to not work? Running dumptable(CHARACTER_INGREDIENT) from in games reveals that the PON entry is indeed in the table, but I believe it gets added after recipe.lua does it's character ingredient checking as IsCharacterIngredient() returns false for my ingredient when it's added this way. I'm not really sure where to go from here, as I don't think there's a way to load code that early into the init process.

Edited by Wonderlarr
Link to comment
Share on other sites

4 hours ago, Rickzzs said:

Maybe you need to hack IsCharacterIngredient, to either set upvalue "is_character_ingredient" as nil, or bypass it if it is your newly added ingredient and just return true.

This is what I ended up doing, just finished up earlier today, thanks for the help!

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...