CreatorKami Posted July 25, 2016 Share Posted July 25, 2016 (edited) Hello, I have been working on a pair of character mods for Don't Starve Together with sanity perks when near one another. I had no problem programming the sanity aura perk when nearby one another, but I also want to program it so when one of the characters is equipped with a specific item, it gives off an insanity aura for the other one. I added this line of code to both of the mod characters' character prefabs, but what should I do for the insanity aura when the other is equipped with a certain item. Basically, the premise is that one of the characters is terrified of knives, and their partner has a custom item knife. So seeing their partner equipped with this custom knife should lower their sanity (medium loss). inst:AddComponent("sanityaura") inst.components.sanityaura.aurafn = function(inst, observer) if observer.prefab == "characterprefab" then return TUNING.SANITYAURA_TINY end end For anyone willing to help, it's much appreciated! Edited July 25, 2016 by CreatorKami Link to comment https://forums.kleientertainment.com/forums/topic/69099-help-with-a-perk/ Share on other sites More sharing options...
IvanX Posted July 25, 2016 Share Posted July 25, 2016 (edited) You should also check inst.components.inventory for equipped items. The functions for that can be found in "components/inventory.lua" Here's a short list of other functions you may be interested in: function Inventory:EquipHasTag(tag) -- AddTag('sharp') to your knife prefab and then check inst.components.inventory:EquipHasTag('sharp') - this will return TRUE if the other player has item with current tag in one of the equip slots function Inventory:Has(item, amount) -- pass item (as prefab name), and 1 as amount if player has at least one of the items in the inventory it will return {true, number} Edited July 25, 2016 by IvanX Link to comment https://forums.kleientertainment.com/forums/topic/69099-help-with-a-perk/#findComment-796812 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