SquareRoot Posted June 7, 2015 Share Posted June 7, 2015 Hello!I'm making a character mod, but I don't know much about coding. I'm done with pretty much everything but I can't figure out how to make a certain perk work - I need my character to lose sanity every time they eat vegetables. Could I ask for a tip?Thanks a lot~ Link to comment https://forums.kleientertainment.com/forums/topic/54953-help-with-simple-coding/ Share on other sites More sharing options...
Blueberrys Posted June 7, 2015 Share Posted June 7, 2015 @SquareRootinst:ListenForEvent("oneat", function(inst, data) -- When you eat something if data.food.components.edible.foodtype == "VEGGIE" then -- If it's a veggie inst.components.sanity:DoDelta(-10) -- Decrease sanity endend) Link to comment https://forums.kleientertainment.com/forums/topic/54953-help-with-simple-coding/#findComment-644979 Share on other sites More sharing options...
SquareRoot Posted June 7, 2015 Author Share Posted June 7, 2015 @SquareRootinst:ListenForEvent("oneat", function(inst, data) -- When you eat something if data.food.components.edible.foodtype == "VEGGIE" then -- If it's a veggie inst.components.sanity:DoDelta(-10) -- Decrease sanity endend)Sorry to bother, but where do I place this? I tried adding it to modmain.lua and it didn't work- Apologies for the stupid questions ahh... Link to comment https://forums.kleientertainment.com/forums/topic/54953-help-with-simple-coding/#findComment-644981 Share on other sites More sharing options...
Blueberrys Posted June 7, 2015 Share Posted June 7, 2015 @SquareRoot In a place where the inst variable refers to your player instance. Usually, that's in your player file, inside the "fn" function. Link to comment https://forums.kleientertainment.com/forums/topic/54953-help-with-simple-coding/#findComment-645010 Share on other sites More sharing options...
SquareRoot Posted June 8, 2015 Author Share Posted June 8, 2015 Oh! Okay!Thanks a lot!! Link to comment https://forums.kleientertainment.com/forums/topic/54953-help-with-simple-coding/#findComment-645175 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