Hyaciao Posted May 17, 2015 Share Posted May 17, 2015 (edited) Back again, with another problem. I've done some trial and error and found that the food pref is done like this in order to get a character to have a food diet of only eating meat. inst.components.eater:SetDiet({FOODGROUP.OMNI}, {FOODTYPE.MEAT})Unfortunately this only helped me so far because i'm trying to make my character eat only fresh food (so disable eating stale/spoiled altogether). Stale and spoil aren't exactly a type and I'm not quite sure how to make it check for perish counter. Am I approaching this the wrong way? Edited May 17, 2015 by Hyaciao Link to comment https://forums.kleientertainment.com/forums/topic/54117-help-preventing-character-from-eating-spoiled-food/ Share on other sites More sharing options...
Seiai Posted May 18, 2015 Share Posted May 18, 2015 u will probably have to override the CanEat-function in the component eater.something likeinst.components.eater.CanEat=function(item) if --make some check here, to check if the item is stale then return false end return self:TestFood(item, self.caneat)end Link to comment https://forums.kleientertainment.com/forums/topic/54117-help-preventing-character-from-eating-spoiled-food/#findComment-638428 Share on other sites More sharing options...
DarkXero Posted May 18, 2015 Share Posted May 18, 2015 Yes, you can override CanEat to override the global options that can be picked to see if the character can eat.You can override the preferences to make the character bail out with food they don't like.local old_pte = inst.components.eater.PrefersToEatinst.components.eater.PrefersToEat = function(self, inst) if inst.components.perishable then if inst.components.perishable:IsStale() or inst.components.perishable:IsSpoiled() then return end end if inst.prefab == "spoiled_food" then return end return old_pte(self, inst)end Link to comment https://forums.kleientertainment.com/forums/topic/54117-help-preventing-character-from-eating-spoiled-food/#findComment-638446 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