Jump to content

Recommended Posts

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 by Hyaciao

u will probably have to override the CanEat-function in the component eater.

something like

inst.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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...