MichaelMax Posted February 25, 2015 Share Posted February 25, 2015 Hi!I'm trying to make my custom character hate wearing any kind of armor and lose sanity while wearing them. But I am having some trouble with it and I'd like some help. I don't know much about programming but I tried my best. Sorry for any English errors, I speak portuguese. I started making it listen to the equip event. When he equips the item he starts losing sanity:inst:ListenForEvent("equip", unequip) -- master_postinitlocal function unequip(inst, data) if data.item and data.item.components.armor then inst.components.sanity:DoDelta(TUNING.CRAZINESS_SMALL) endendBut it only makes he loses sanity in the moment he equips the item and not while wearing it. Furthermore, I tried using only equip instead of unequip to see if it works, but it didn't (I didn't even know if that exists). So, if someone can help me I would be very thankful. Link to comment https://forums.kleientertainment.com/forums/topic/51418-help-character-mod-sanity-drain-when-equiping-armor/ Share on other sites More sharing options...
DarkXero Posted February 25, 2015 Share Posted February 25, 2015 local old = inst.components.sanity.custom_rate_fn local d = 0 inst.components.sanity.custom_rate_fn = function(inst) if old then d = old(inst) end if inst.components.inventory and inst.components.inventory:IsWearingArmor() then return -TUNING.DAPPERNESS_LARGE + d else return 0 + d end end Link to comment https://forums.kleientertainment.com/forums/topic/51418-help-character-mod-sanity-drain-when-equiping-armor/#findComment-616459 Share on other sites More sharing options...
MichaelMax Posted February 25, 2015 Author Share Posted February 25, 2015 I'm sorry DarkXero, but I can't figure out where to add this. I tried a lot but it always crashed.Can you explain me where do I put these, please? Link to comment https://forums.kleientertainment.com/forums/topic/51418-help-character-mod-sanity-drain-when-equiping-armor/#findComment-616579 Share on other sites More sharing options...
DarkXero Posted February 25, 2015 Share Posted February 25, 2015 In your master postinit of your character prefab. If you still run into trouble you canTUNING = GLOBAL.TUNINGAddPrefabPostInit("MyCharacter", function(inst) --The codeend)in modmain.lua. Link to comment https://forums.kleientertainment.com/forums/topic/51418-help-character-mod-sanity-drain-when-equiping-armor/#findComment-616585 Share on other sites More sharing options...
MichaelMax Posted February 25, 2015 Author Share Posted February 25, 2015 Thanks a lot! It worked! It was not working because I thought I needed to put the local things separeted of the inst.components... like I did before Link to comment https://forums.kleientertainment.com/forums/topic/51418-help-character-mod-sanity-drain-when-equiping-armor/#findComment-616591 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