Jump to content

Help with mod


Recommended Posts

Hello I am working on a character to DST but unfortunately I can't find a way to make him poop while eating

local function OnEat(inst, food) 

    if food.components.edible and food.components.edible.foodtype == "VEGGIE" then --poop
        local poo = SpawnPrefab("poop")
        poo.Transform:SetPosition(inst.Transform:GetClosestInstWithTag("player", inst, MyRadius)())        
    end
end



local function fn(Sim)



    inst:AddComponent("eater")
    inst.components.eater:SetOmnivore() -- all standard foodtypes besides wood, elemental and horrible --add horrible
    inst.components.eater.strongstomach = true -- can eat monster meat
    inst.components.eater:SetOnEatFn(OnEat)

 

    return inst

end

I tried to use part of the Pigman code but it does not work. I would be really grateful if someone would give me some help c:

(Sorry for my bad english)

Link to comment
Share on other sites

Try putting the




    inst:AddComponent("eater")
    inst.components.eater:SetOmnivore() -- all standard foodtypes besides wood, elemental and horrible --add horrible
    inst.components.eater.strongstomach = true -- can eat monster meat
    inst.components.eater:SetOnEatFn(OnEat)

in the masterpostinit of your character, maybe ?

Link to comment
Share on other sites

If you want your character to poop from eating veggies u can do something like this I think in his master_postinit in YOURCHARACTER.lua

inst:ListenForEvent("oneat", function(inst, data) 
	if data.food and data.food.components.edible and data.food.components.edible.foodtype == "VEGGIE" and inst.poop_cooldown == nil then
		inst.poop_cooldown = true
		inst:DoTaskInTime(480, function() inst.poop_cooldown = nil end) -- 480 = 1 DS day or u can put whatever amount of seconds u want
		local x, y, z = inst.Transform:GetWorldPosition()
		SpawnPrefab("poop").Transform:SetPosition(inst.Transform:GetWorldPosition())
	end
end)

 

Edited by SuperDavid
Link to comment
Share on other sites

2 hours ago, Lumina said:

Try putting the





    inst:AddComponent("eater")
    inst.components.eater:SetOmnivore() -- all standard foodtypes besides wood, elemental and horrible --add horrible
    inst.components.eater.strongstomach = true -- can eat monster meat
    inst.components.eater:SetOnEatFn(OnEat)

in the masterpostinit of your character, maybe ?

Seems to crash the game

 

47 minutes ago, SuperDavid said:

If you want your character to poop from eating veggies u can do something like this I think in his master_postinit in YOURCHARACTER.lua


inst:ListenForEvent("oneat", function(inst, data) 
	if data.food and data.food.components.edible and data.food.components.edible.foodtype == "VEGGIE" and inst.poop_cooldown == nil then
		inst.poop_cooldown = true
		inst:DoTaskInTime(480, function() inst.poop_cooldown = nil end) -- 480 = 1 DS day or u can put whatever amount of seconds u want
		local x, y, z = inst.Transform:GetWorldPosition()
		SpawnPrefab("poop").Transform:SetPosition(inst.Transform:GetWorldPosition())
	end
end)

 

Seems to work just fine :)

 

Thank you very much

Link to comment
Share on other sites

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
 Share

×
  • Create New...