Aileen-Rose Posted March 11, 2017 Share Posted March 11, 2017 So I have this mod I'm making for someone and well... they've got a rather odd diet. Here's the low down, I need a set of codes that can basically do this: He can only eat foods that are stale or rotten, like stale berries or slop restore more health and hunger , where eating fresh berries deals damage and drains his hunger And he can eat monster meat safely without as bad negative effects, like Webber can. I got the iron stomach part cracked I just can't for the life of me figure out how to make fresh foods be detrimental like how Wickerbottom is to stale or spoiled foods. If I could get some help on this I would really really appreciate it. This mod is pretty much done save this last part. Link to comment Share on other sites More sharing options...
minespatch Posted March 11, 2017 Share Posted March 11, 2017 Sounds like a zombie character. Link to comment Share on other sites More sharing options...
. . . Posted March 11, 2017 Share Posted March 11, 2017 (edited) I couldn't exactly tell what you want, all I could understand is you want penalties from eating fresh food, right? If so then this code will make your character take penalty when the food is fresh & bonus from stale & spoiled Spoiler inst:ListenForEvent("oneat", function(inst, data) if data.food.components.perishable:IsFresh() then inst.components.sanity:DoDelta(-10) inst.components.health:DoDelta(-10) inst.components.talker:Say("It burns!") elseif data.food.components.perishable:IsStale() then inst.components.sanity:DoDelta(5) inst.components.health:DoDelta(5) inst.components.talker:Say("Tasty!") elseif data.food.components.perishable:IsSpoiled() then inst.components.sanity:DoDelta(10) inst.components.health:DoDelta(10) inst.components.talker:Say("So delicious!") end end) if you also want your character to receive no sanity or health bonus from fresh food you can put this code as well Spoiler inst.components.eater.Eat_orig = inst.components.eater.Eat function inst.components.eater:Eat(food) if food and food.components.edible and self:CanEat(food) and food.components.perishable:IsFresh() then if food.components.edible.sanityvalue > 0 then food.components.edible.sanityvalue = 0 end if food.components.edible.healthvalue > 0 then food.components.edible.healthvalue = 0 end end return inst.components.eater:Eat_orig(food) end put both of these inside your character's master_postinit area , hopefully this is what you wanted ! Edited March 11, 2017 by SuperDavid forgot to put a "then" in the code Link to comment Share on other sites More sharing options...
Aileen-Rose Posted March 11, 2017 Author Share Posted March 11, 2017 9 minutes ago, SuperDavid said: I couldn't exactly tell what you want, all I could understand is you want penalties from eating fresh food, right? If so then this code will make your character take penalty when the food is fresh & bonus from stale & spoiled Reveal hidden contents inst:ListenForEvent("oneat", function(inst, data) if data.food.components.perishable:IsFresh() then inst.components.sanity:DoDelta(-10) inst.components.health:DoDelta(-10) inst.components.talker:Say("It burns!") elseif data.food.components.perishable:IsStale() then inst.components.sanity:DoDelta(5) inst.components.health:DoDelta(5) inst.components.talker:Say("Tasty!") elseif data.food.components.perishable:IsSpoiled() then inst.components.sanity:DoDelta(10) inst.components.health:DoDelta(10) inst.components.talker:Say("So delicious!") end end) if you also want your character to receive no sanity or health bonus from fresh food you can put this code as well Reveal hidden contents inst.components.eater.Eat_orig = inst.components.eater.Eat function inst.components.eater:Eat(food) if food and food.components.edible and self:CanEat(food) and food.components.perishable:IsFresh() then if food.components.edible.sanityvalue > 0 then food.components.edible.sanityvalue = 0 end if food.components.edible.healthvalue > 0 then food.components.edible.healthvalue = 0 end end return inst.components.eater:Eat_orig(food) end put both of these inside your character's master_postinit area , hopefully this is what you wanted ! AAAAH!!!!! This is exactly what I needed! It works great! Thank you thank you thank you so much! Link to comment Share on other sites More sharing options...
DragonMage156 Posted March 11, 2017 Share Posted March 11, 2017 What an odd but interesting perk. Link to comment Share on other sites More sharing options...
Aileen-Rose Posted March 11, 2017 Author Share Posted March 11, 2017 2 minutes ago, DragonMage156 said: What an odd but interesting perk. It is weird, but in context of the character it is for, it makes sense. Link to comment Share on other sites More sharing options...
DragonMage156 Posted March 11, 2017 Share Posted March 11, 2017 13 minutes ago, Aileen-Rose said: It is weird, but in context of the character it is for, it makes sense. So what is it or should I just wait for the mod release? Link to comment Share on other sites More sharing options...
Aileen-Rose Posted March 11, 2017 Author Share Posted March 11, 2017 Just now, DragonMage156 said: So what is it or should I just wait for the mod release? Wait till the release. =) Link to comment Share on other sites More sharing options...
DatShadowJK Posted March 11, 2017 Share Posted March 11, 2017 (edited) 2 hours ago, Aileen-Rose said: He can only eat foods that are stale or rotten, like stale berries or slop restore more health and hunger , where eating fresh berries deals damage and drains his hunger Should he have it that he starves slower since SOME foods take a while to get into stale? Also, can he eat Powdercakes? (-3 Health Item that takes, uh, over 10000 days to perish) - By the way, I would definitely try this mod when it comes out Edited March 11, 2017 by DatShadowJK Link to comment Share on other sites More sharing options...
Aileen-Rose Posted March 11, 2017 Author Share Posted March 11, 2017 Just now, DatShadowJK said: Should he have it that he starves slower since SOME foods take a while to get into stale? Also, can he eat Powdercakes? (-3 Health Item that takes, uh, over 10000 days to perish) Funny you should mention that since that is another perk this character in question has. Link to comment Share on other sites More sharing options...
DatShadowJK Posted March 11, 2017 Share Posted March 11, 2017 (edited) 7 minutes ago, Aileen-Rose said: Funny you should mention that since that is another perk this character in question has. Heh, awesome.. (If I were to host a server with this guy, people would be offering fresh food to me, oh God..) Edited March 11, 2017 by DatShadowJK Link to comment 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