Nycidian Posted October 9, 2013 Share Posted October 9, 2013 Because in my mod I have added new ingredients I had to rewrite what each normal recipe takes so that they mostly would not use the new ingredients. The only way I new how to do that was by redeclaring them whole in the modmain.lua file like the following. meatballs ={name = "meatballs",test = function(cooker, names, tags) return tags.meat and not tags.rock and not tags.inedible and not tags.rock and not tags.collagen and not tags.horrible end,priority = -1,weight = 1,foodtype = "MEAT",health = TUNING.HEALING_SMALL,hunger = TUNING.CALORIES_SMALL*5,perishtime = TUNING.PERISH_MED,sanity = TUNING.SANITY_TINY,cooktime = .75,}AddCookerRecipe("cookpot", meatballs) Is there a way to only rewrite the "test" part of the above? Using the above method works but I have a feeling it will interfere with other mods that mess with food, not to mention it is tedious and clunky. Link to comment https://forums.kleientertainment.com/forums/topic/28628-coding-question/ Share on other sites More sharing options...
squeek Posted October 9, 2013 Share Posted October 9, 2013 In cooking.lua, you can find the AddCookerRecipe function. It adds the recipe to a local table that gets returned by the file. Therefore, you should be able to do something like this:-- if in modmain, you'll need this linelocal require = GLOBAL.requirelocal cooking = require "cooking"-- require "cooking" will return a table; the recipes key is what we're afterlocal recipes = cooking.recipes-- recipes are stored by cooker name and then recipe namerecipes.cookpot.meatballs.test = function(cooker, names, tags) return tags.meat and not tags.rock and not tags.inedible and not tags.rock and not tags.collagen and not tags.horrible end 2 Link to comment https://forums.kleientertainment.com/forums/topic/28628-coding-question/#findComment-340305 Share on other sites More sharing options...
Nycidian Posted October 10, 2013 Author Share Posted October 10, 2013 Thanks that's what I needed Link to comment https://forums.kleientertainment.com/forums/topic/28628-coding-question/#findComment-340386 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