Jump to content

Recommended Posts

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?

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)

 

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?

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.

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.

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?

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.

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

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

 

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