Chesed Posted April 6, 2022 Share Posted April 6, 2022 (edited) Hello, me again, working on someone else's mod this time. I'm making a tool for a character mod. It's a needle that, when held in the hand slot, allows the character to craft special clothing. Crafting with the needle causes the needle's durability to go down. I've gotten it working for the most part, but hit a snag with the durability depletion. Looking at the green amulet's code, I found this in OnEquip: Quote inst.onitembuild = function() inst.components.finiteuses:Use(1) end inst:ListenForEvent("consumeingredients", inst.onitembuild, owner) ...which works as a foundation. However, I don't know how to check for what item is being crafted so the game knows whether or not to reduce the needle's durability. Currently it depletes no matter what is being crafted, just like the green amulet. Is there any straightfoward way to add a check for a tag or a prefab name to this function so that the needle depletes properly? Since this is someone else's mod I'm helping with, I want to give it a fair shot before restorting to making the needle function differently to what they want. Thanks for reading. Edited April 6, 2022 by Chesed Link to comment https://forums.kleientertainment.com/forums/topic/138898-solved-reduce-tool-durability-when-certain-item-is-crafted/ Share on other sites More sharing options...
Monti18 Posted April 6, 2022 Share Posted April 6, 2022 You can listen for the event "builditem" instead of "consumeingredients". inst.onitembuild = function(player,data) if data and data.recipe and data.recipe.name == "your_recipe_name" then inst.components.finiteuses:Use(1) end end inst:ListenForEvent("builditem", inst.onitembuild, owner) This should work I think 1 Link to comment https://forums.kleientertainment.com/forums/topic/138898-solved-reduce-tool-durability-when-certain-item-is-crafted/#findComment-1555626 Share on other sites More sharing options...
Chesed Posted April 6, 2022 Author Share Posted April 6, 2022 Looks like it's working perfectly, thank you so much for the help!! 1 Link to comment https://forums.kleientertainment.com/forums/topic/138898-solved-reduce-tool-durability-when-certain-item-is-crafted/#findComment-1555639 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