kelsuis Posted May 1, 2016 Share Posted May 1, 2016 (edited) I'm trying to port character from DST that used to eat only minerals by using this code line, but it doesn't work in DS. inst.components.eater:SetDiet({ FOODTYPE.ELEMENTAL }, { FOODTYPE.ELEMENTAL }) character basically eat the same thing Rocky will take from player. I'd look into his prefab and found this along with what in eater prefab inst.components.eater:SetElemental() -- Rocky function Eater:SetElemental(human) -- eater self.foodprefs = {"ELEMENTAL"} if human then self.ablefoods = { "MEAT", "VEGGIE", "INSECT", "SEEDS", "GENERIC", "ELEMENTAL" } else self.ablefoods = { "ELEMENTAL" } end end using inst.components.eater:SetElemental() end up unable to eat anything at all. so I try to set it individual with these instead, still not work. inst.components.eater.foodprefs = {"ELEMENTAL"} inst.components.eater.ablefoods = {"ELEMENTAL"} as in not work character will only examine an items unable to eat it. I'm out of idea how to solve this. Edit 1 : rocks prefab doesn't have eddible companent, but gem has. at least it should work on gem as i understand. Edited May 1, 2016 by kelsuis add more info Link to comment https://forums.kleientertainment.com/forums/topic/66863-trying-to-make-character-eat-elemental-foodtype/ Share on other sites More sharing options...
Kronodie Posted May 6, 2016 Share Posted May 6, 2016 Try this one : inst.components.eater.SetCanEatElemental() Link to comment https://forums.kleientertainment.com/forums/topic/66863-trying-to-make-character-eat-elemental-foodtype/#findComment-767575 Share on other sites More sharing options...
DarkXero Posted May 6, 2016 Share Posted May 6, 2016 On 1/5/2016 at 11:15 PM, kelsuis said: rocks prefab doesn't have eddible companent, but gem has. at least it should work on gem as i understand. rock.lua are the boulders. inv_rocks.lua are the rocks, which are ELEMENTAL. The problem you are having, is that in RoG and SW, IsValidFood method in the eater component exists. function Eater:IsValidFood(food) if self.inst == GetPlayer() and food.components.edible.foodtype == "ELEMENTAL" then return false Which makes you not eat ELEMENTAL. You need: inst.components.eater:SetElemental() local _IsValidFood = inst.components.eater.IsValidFood if _IsValidFood then inst.components.eater.IsValidFood = function(self, food) if self.inst == GetPlayer() and food.components.edible.foodtype == "ELEMENTAL" then return true end return _IsValidFood(self, food) end end Link to comment https://forums.kleientertainment.com/forums/topic/66863-trying-to-make-character-eat-elemental-foodtype/#findComment-767604 Share on other sites More sharing options...
kelsuis Posted May 7, 2016 Author Share Posted May 7, 2016 14 hours ago, DarkXero said: rock.lua are the boulders. inv_rocks.lua are the rocks, which are ELEMENTAL. The problem you are having, is that in RoG and SW, IsValidFood method in the eater component exists. function Eater:IsValidFood(food) if self.inst == GetPlayer() and food.components.edible.foodtype == "ELEMENTAL" then return false Which makes you not eat ELEMENTAL. You need: inst.components.eater:SetElemental() local _IsValidFood = inst.components.eater.IsValidFood if _IsValidFood then inst.components.eater.IsValidFood = function(self, food) if self.inst == GetPlayer() and food.components.edible.foodtype == "ELEMENTAL" then return true end return _IsValidFood(self, food) end end It's work now. Thank you so much. I will never know that component exist. really appreciated. Link to comment https://forums.kleientertainment.com/forums/topic/66863-trying-to-make-character-eat-elemental-foodtype/#findComment-768032 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