Jump to content

Removing bad effects from mushroom for my characters

Recommended Posts

Hello again! I'm still working on my character.


I wanted that when she eats mushrooms, she level up and gain a small amount of health. I succeed with that code:



if food and food.components.edible and food.prefab == "red_cap" or food.prefab == "green_cap" or food.prefab == "blue_cap" then

--give an upgrade!
inst.level = inst.level + 1


But how do you remove the bad effects from the mushrooms eaten raw ? Because ingame, my character is still hurts by the mushroom and says that it wasn't good.


Thanks you!

Link to comment
Share on other sites

@PtitENoli, I was referring to this part:

Add this to your master_postinit in the character prefab file:

local OldEat = inst.components.eater.Eatinst.components.eater.Eat = function(self, food)    if self:CanEat(food) and food.prefab:find("berries") then        food.components.edible.healthvalue = food.components.edible.healthvalue + 5    end    return OldEat(self, food)end
That should work for both cooked and raw berries. If you want just one of them, change the food.prefab:find() part to food.prefab == "berries" or "berries_cooked".


You can use the same approach, targeted to the prefab names of the mushrooms, to modify their food values for just your character.

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

  • Create New...