Developer PeterA Posted April 28, 2015 Developer Share Posted April 28, 2015 Hey everyone, I updated the mod api while we were adding Reign of Giants content to DST, and now those API changes are available to everyone. In particular, I added a new API to add recipes that will allow multiple mods to add recipes without conflict. Instead of using the Recipe constructor or Recipe mod API, instead you should call AddRecipe from modmain. I've updated the Soulmates mod to use this new API. I've tried to make is so that changing to this new method is as easy as possible. -this code was previously in my prefab def lua fileRecipe("bindingring", {Ingredient("goldnugget", 10),Ingredient("moonrocknugget", 1)}, RECIPETABS.MAGIC, TECH.NONE)AllRecipes["bindingring"].atlas = resolvefilepath("images/inventoryimages/bindingring.xml")--now it it is replaced with the following code in your modmain.lualocal Ingredient = GLOBAL.IngredientAddRecipe("bindingring", {Ingredient("goldnugget", 10), Ingredient("moonrocknugget", 1)}, GLOBAL.RECIPETABS.MAGIC, GLOBAL.TECH.NONE, nil, nil, nil, nil, nil, "images/inventoryimages/bindingring.xml", "bindingring.tex" )The main difference here is that you call AddRecipe instead of Recipe. This was changed to make it clearer that you're calling the API function and not the Recipe's constructor. Also, the function needs to be called from modmain so that we know automatically which mod the recipes belongs to, which is how we handle the inter-mod compatibility.The last two parameters are new, and are an optional atlas and image. You no longer need to resolve and assign the atlas file in a second step. Existing mods should continue to function, but if they were previously calling into the Recipe constructor, you'll still have potential mod compatibility problems, and should get warnings printed into your log.txt. Also as a consequence of this change, your mods will be able to modify the recipe's sortkey without affecting the RPC communication. Please let me know if you have any questions! Link to comment https://forums.kleientertainment.com/forums/topic/53321-mod-api-update-addrecipe/ Share on other sites More sharing options...
Quiet Posted April 28, 2015 Share Posted April 28, 2015 Link to comment https://forums.kleientertainment.com/forums/topic/53321-mod-api-update-addrecipe/#findComment-632947 Share on other sites More sharing options...
Silentdarkness1 Posted April 29, 2015 Share Posted April 29, 2015 Oh good. More log.txt spam. Link to comment https://forums.kleientertainment.com/forums/topic/53321-mod-api-update-addrecipe/#findComment-632982 Share on other sites More sharing options...
Developer PeterA Posted April 29, 2015 Author Developer Share Posted April 29, 2015 Oh good. More log.txt spam. It's not spam, it's useful debug data for the modders to know why their mods are failing to work correctly. I assume most modders would prefer the log warnings, rather than their mod simply becoming broken when the old functionality is removed. On a side note, I recently removed a bunch of the actual spam from the startup sequence (GL prints and invalid prefab warnings), so you should see a more readable log.txt now. Link to comment https://forums.kleientertainment.com/forums/topic/53321-mod-api-update-addrecipe/#findComment-632987 Share on other sites More sharing options...
Silentdarkness1 Posted April 29, 2015 Share Posted April 29, 2015 Sorry. I just have nightmares regarding poorly-coded mods that made the game lag with all the log.txt recording when player sanity got low. Which caused my sanity to get low. Link to comment https://forums.kleientertainment.com/forums/topic/53321-mod-api-update-addrecipe/#findComment-632990 Share on other sites More sharing options...
Developer PeterA Posted April 29, 2015 Author Developer Share Posted April 29, 2015 @Silentdarkness1, the warning only gets printed once when the mod is initialized, so it shouldn't affect the performance of the game. Link to comment https://forums.kleientertainment.com/forums/topic/53321-mod-api-update-addrecipe/#findComment-632993 Share on other sites More sharing options...
Silentdarkness1 Posted April 29, 2015 Share Posted April 29, 2015 Good.....don't need more nightmares. Link to comment https://forums.kleientertainment.com/forums/topic/53321-mod-api-update-addrecipe/#findComment-632995 Share on other sites More sharing options...
CarlZalph Posted April 29, 2015 Share Posted April 29, 2015 (edited) For others looking into this, the arguments for AddRecipe match the constructor for Recipe found at /data/scripts/recipe.lua, currently:(name, ingredients, tab, level, placer, min_spacing, nounlock, numtogive, builder_tag, atlas, image) Edited April 29, 2015 by CarlZalph Link to comment https://forums.kleientertainment.com/forums/topic/53321-mod-api-update-addrecipe/#findComment-633005 Share on other sites More sharing options...
Developer PeterA Posted April 29, 2015 Author Developer Share Posted April 29, 2015 @CarlZalph, yup! Thanks for pointing that out. Link to comment https://forums.kleientertainment.com/forums/topic/53321-mod-api-update-addrecipe/#findComment-633017 Share on other sites More sharing options...
ForenSmurf Posted May 12, 2015 Share Posted May 12, 2015 It's not spam, it's useful debug data for the modders to know why their mods are failing to work correctly. I assume most modders would prefer the log warnings, rather than their mod simply becoming broken when the old functionality is removed. On a side note, I recently removed a bunch of the actual spam from the startup sequence (GL prints and invalid prefab warnings), so you should see a more readable log.txt now. Thank you! I need every debug-data i can get and for mods i even like to have more Maybe you can entangle it with the "EnableModDebugPrint()"-Switch in modsettings.lua? The issue i'm dealing with right now is that i have at least one mod on my server which is causing severe performance issues (but not all the time) but i just can't figure out which mods are causing problems, because the log is giving absolutely no clue about it. ofcourse i'm consistently trying to turn off/turn on some mods and experiment with the results but because i have to test quite a number of cases it does taking forever :/ Link to comment https://forums.kleientertainment.com/forums/topic/53321-mod-api-update-addrecipe/#findComment-636893 Share on other sites More sharing options...
DracoS2 Posted June 10, 2022 Share Posted June 10, 2022 (edited) I have one question though: How to add recipe with 2 items as an outcome?? Edited June 10, 2022 by DracoS2 Link to comment https://forums.kleientertainment.com/forums/topic/53321-mod-api-update-addrecipe/#findComment-1576165 Share on other sites More sharing options...
Wonderlarr Posted June 10, 2022 Share Posted June 10, 2022 2 minutes ago, DracoS2 said: I have one question though: How to add recipe with 2 items as an outcome?? This post is over 7 years old my dude, you may wanna make a new thread in the future, lol. Are you using AddRecipe, AddRecipe2, or AddCharacterRecipe? 1 Link to comment https://forums.kleientertainment.com/forums/topic/53321-mod-api-update-addrecipe/#findComment-1576166 Share on other sites More sharing options...
DracoS2 Posted June 10, 2022 Share Posted June 10, 2022 Haha, that's true, this post has been over 7 years old. I'm using "AddRecipe", sir. And about the question, nevermind, I have found the answer just seconds later. It is the fourth "nil" after "Techlevel" which can be changed to the number of outcome Link to comment https://forums.kleientertainment.com/forums/topic/53321-mod-api-update-addrecipe/#findComment-1576170 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now