Jump to content

Recommended Posts

Hi, I try change mole eater items. I wish mole eat meat or something(like a trash can). I use "AddPrefabPostInit" API to change mole eat items, like this.

local function MoleEatItems(prefab)	if(prefab.components.eater == nil) then		prefab:AddComponent("eater")	end	prefab.components.eater:SetDiet({FOODTYPE.MEAT},{FOODTYPE.ELEMENTAL}) 	endAddPrefabPostInit("mole", MoleEatItems)

Run this mod no error, but mole still eat "FOODTYPE.ELEMENTAL" items(flint, rocks....), not eat meat. Anybody could tell me what's wrong?

SetDiet accepts two parameters.

What somebody can eat, and what somebody prefers to eat.

 

What they can eat will be what they have the option EAT on.

What they prefer to eat will be what they won't spit out.

 

When you pass one parameter, the function equates PrefersToEat with CanEat.

prefab.components.eater:SetDiet({FOODTYPE.MEAT, FOODTYPE.ELEMENTAL})

This way, the mole can eat meat and elementals.

And prefers to eat meat and elementals.

Remember to put GLOBAL.FOODTYPE, if you didn't put FOODTYPE = GLOBAL.FOODTYPE elsewhere.

SetDiet accepts two parameters.

What somebody can eat, and what somebody prefers to eat.

 

What they can eat will be what they have the option EAT on.

What they prefer to eat will be what they won't spit out.

 

When you pass one parameter, the function equates PrefersToEat with CanEat.

prefab.components.eater:SetDiet({FOODTYPE.MEAT, FOODTYPE.ELEMENTAL})

This way, the mole can eat meat and elementals.

And prefers to eat meat and elementals.

Remember to put GLOBAL.FOODTYPE, if you didn't put FOODTYPE = GLOBAL.FOODTYPE elsewhere.

 

I refine code but it isn't work. mole still catch flint and rock. not eat meat.

local FOODTYPE = GLOBAL.FOODTYPElocal function MoleEatItems(prefab)	if(prefab.components.eater == nil) then		prefab:AddComponent("eater")	end	prefab.components.eater:SetDiet({FOODTYPE.MEAT, FOODTYPE.ELEMENTAL}) 	endAddPrefabPostInit("mole", MoleEatItems)

Any suggest?

 

@Atena, that's because you are referring to moles stealing stuff.

Moles eat when you feed them stuff.

They steal when grabbing stuff from the ground.

 

They will become interested in grabbing meat if you put:

local function MakeBait(prefab)	prefab:AddTag("molebait")endAddPrefabPostInit("meat", MakeBait)

 

@Atena, that's because you are referring to moles stealing stuff.

Moles eat when you feed them stuff.

They steal when grabbing stuff from the ground.

 

They will become interested in grabbing meat if you put:

local function MakeBait(prefab)	prefab:AddTag("molebait")endAddPrefabPostInit("meat", MakeBait)

 

Yes, I add your code. The mole eta meat. Thank you!

 

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