MF99K Posted May 7, 2016 Share Posted May 7, 2016 I know that most foods in don't starve are categorized by diet group. I believe they are veggie, meat, omi, monster, elemental, crock pot, and I think at least one other. Thus, Wigfrid only eats meats. I was wondering if there's any way to make a character eat everything EXCEPT specific food items. Say, eggplant, for example. How would I get this character to not eat eggplants and still be able to eat everything else? Link to comment https://forums.kleientertainment.com/forums/topic/67092-preventing-characters-from-eating-specific-food-items/ Share on other sites More sharing options...
DarkXero Posted May 7, 2016 Share Posted May 7, 2016 15 hours ago, mf99k said: How would I get this character to not eat eggplants and still be able to eat everything else? local forbidden = { eggplant = true, eggplant_cooked = true, stuffedeggplant = true, } local function EaterChange(inst) if inst.components.eater then local _PrefersToEat = inst.components.eater.PrefersToEat inst.components.eater.PrefersToEat = function(self, food) return _PrefersToEat(self, food) and not forbidden[food.prefab] end end end AddPrefabPostInit("wilson", EaterChange) Link to comment https://forums.kleientertainment.com/forums/topic/67092-preventing-characters-from-eating-specific-food-items/#findComment-768404 Share on other sites More sharing options...
MF99K Posted May 9, 2016 Author Share Posted May 9, 2016 On 5/7/2016 at 4:50 PM, DarkXero said: local forbidden = { eggplant = true, eggplant_cooked = true, stuffedeggplant = true, } local function EaterChange(inst) if inst.components.eater then local _PrefersToEat = inst.components.eater.PrefersToEat inst.components.eater.PrefersToEat = function(self, food) return _PrefersToEat(self, food) and not forbidden[food.prefab] end end end AddPrefabPostInit("wilson", EaterChange) Didn't work. any other suggestions? Link to comment https://forums.kleientertainment.com/forums/topic/67092-preventing-characters-from-eating-specific-food-items/#findComment-769056 Share on other sites More sharing options...
DarkXero Posted May 9, 2016 Share Posted May 9, 2016 9 hours ago, mf99k said: Didn't work. any other suggestions? It didn't work with Wilson? Or you mean you can't eat everything? To eat everything you need something like: local everything = { FOODTYPE.GENERIC, FOODTYPE.MEAT, FOODTYPE.WOOD, FOODTYPE.VEGGIE, FOODTYPE.ELEMENTAL, FOODTYPE.GEARS, FOODTYPE.HORRIBLE, FOODTYPE.INSECT, FOODTYPE.SEEDS, FOODTYPE.RAW, FOODTYPE.BURNT, FOODTYPE.ROUGHAGE, } inst.components.eater:SetDiet(everything) And then apply the EaterChange code. Link to comment https://forums.kleientertainment.com/forums/topic/67092-preventing-characters-from-eating-specific-food-items/#findComment-769253 Share on other sites More sharing options...
MF99K Posted May 9, 2016 Author Share Posted May 9, 2016 I mean, regular human, "OMNI" diet, but minus eggplant etc. Link to comment https://forums.kleientertainment.com/forums/topic/67092-preventing-characters-from-eating-specific-food-items/#findComment-769370 Share on other sites More sharing options...
DarkXero Posted May 10, 2016 Share Posted May 10, 2016 4 hours ago, mf99k said: I mean, regular human, "OMNI" diet, but minus eggplant etc. Then the code I provided initially should work. You change "wilson" for the prefab you want. It will work like how Wigfrid gets the Eat prompt but won't actually eat the veggie. Link to comment https://forums.kleientertainment.com/forums/topic/67092-preventing-characters-from-eating-specific-food-items/#findComment-769499 Share on other sites More sharing options...
MF99K Posted May 10, 2016 Author Share Posted May 10, 2016 46 minutes ago, DarkXero said: Then the code I provided initially should work. You change "wilson" for the prefab you want. It will work like how Wigfrid gets the Eat prompt but won't actually eat the veggie. what if I want to set it up directly in the character prefab? Link to comment https://forums.kleientertainment.com/forums/topic/67092-preventing-characters-from-eating-specific-food-items/#findComment-769521 Share on other sites More sharing options...
DarkXero Posted May 10, 2016 Share Posted May 10, 2016 2 minutes ago, mf99k said: what if I want to set it up directly in the character prefab? local forbidden = { eggplant = true, eggplant_cooked = true, stuffedeggplant = true, } local _PrefersToEat = inst.components.eater.PrefersToEat inst.components.eater.PrefersToEat = function(self, food) return _PrefersToEat(self, food) and not forbidden[food.prefab] end inside master_postinit. Link to comment https://forums.kleientertainment.com/forums/topic/67092-preventing-characters-from-eating-specific-food-items/#findComment-769522 Share on other sites More sharing options...
MF99K Posted May 13, 2016 Author Share Posted May 13, 2016 On 5/10/2016 at 7:36 PM, DarkXero said: local forbidden = { eggplant = true, eggplant_cooked = true, stuffedeggplant = true, } local _PrefersToEat = inst.components.eater.PrefersToEat inst.components.eater.PrefersToEat = function(self, food) return _PrefersToEat(self, food) and not forbidden[food.prefab] end inside master_postinit. Still isn't working another thing I was working on, a way to prevent the character from eating at full hunger Link to comment https://forums.kleientertainment.com/forums/topic/67092-preventing-characters-from-eating-specific-food-items/#findComment-771152 Share on other sites More sharing options...
DrSmugleaf Posted May 13, 2016 Share Posted May 13, 2016 5 hours ago, mf99k said: another thing I was working on, a way to prevent the character from eating at full hunger In the master_postinit: local old_Eat = inst.components.eater.Eat inst.components.eater.Eat = function(food, feeder) if inst.components.eater.inst.components.hunger:GetPercent() == 1 then return false else return old_Eat(food, feeder) end end Link to comment https://forums.kleientertainment.com/forums/topic/67092-preventing-characters-from-eating-specific-food-items/#findComment-771232 Share on other sites More sharing options...
DarkXero Posted May 13, 2016 Share Posted May 13, 2016 7 hours ago, mf99k said: Still isn't working Are you using the code for DST or DS? Link to comment https://forums.kleientertainment.com/forums/topic/67092-preventing-characters-from-eating-specific-food-items/#findComment-771272 Share on other sites More sharing options...
MF99K Posted June 2, 2016 Author Share Posted June 2, 2016 On 5/13/2016 at 10:48 AM, DarkXero said: Are you using the code for DST or DS? I fixed it, I accidentally missed a line of code. Link to comment https://forums.kleientertainment.com/forums/topic/67092-preventing-characters-from-eating-specific-food-items/#findComment-779097 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