Atena Posted May 18, 2015 Share Posted May 18, 2015 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? Link to comment https://forums.kleientertainment.com/forums/topic/54128-helphow-to-change-eater-items-by-componentseatersetdiet/ Share on other sites More sharing options...
DarkXero Posted May 18, 2015 Share Posted May 18, 2015 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. Link to comment https://forums.kleientertainment.com/forums/topic/54128-helphow-to-change-eater-items-by-componentseatersetdiet/#findComment-638464 Share on other sites More sharing options...
Atena Posted May 18, 2015 Author Share Posted May 18, 2015 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? Link to comment https://forums.kleientertainment.com/forums/topic/54128-helphow-to-change-eater-items-by-componentseatersetdiet/#findComment-638479 Share on other sites More sharing options...
DarkXero Posted May 18, 2015 Share Posted May 18, 2015 @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) Link to comment https://forums.kleientertainment.com/forums/topic/54128-helphow-to-change-eater-items-by-componentseatersetdiet/#findComment-638481 Share on other sites More sharing options...
Atena Posted May 18, 2015 Author Share Posted May 18, 2015 @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! Link to comment https://forums.kleientertainment.com/forums/topic/54128-helphow-to-change-eater-items-by-componentseatersetdiet/#findComment-638490 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