Jump to content

Recommended Posts

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 by kelsuis
add more info
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

 

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.

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