Jump to content

Specific food timer for a mod character


Recommended Posts

Hi I'm making a character mod as a birthday present for my friend (actually the mod adds my friend as a playable character). And I want to make a dependence on a specific food one of the perks (a new recipe will also be added). The essence of mechanics is the loss of reason with a long disuse of the dish. Can you help with this?

Link to comment
Share on other sites

Depends on how often you'd want the game to check that your character hasn't ate the food in awhile. You have a food options in that regard, checking when a new day happens, checking when hunger changes, checking when you eat something that isn't that food, simply checking periodically (more taxing on the server but likely still ok to do), etc. I'm not sure which you'd like to use or which would be the best option for what you want to do. Most of these can be done with a ListenForEvent, and you can find what events get pushed by searching for PushEvent in the game's files

For actually knowing that your character ate the food, its as simple as either giving the food item a specific tag exclusive to itself or checking the prefab name of the food whenever your character eats something. I do recommend looking through the game's files when you want to try to figure something out, a lot of the times it ends up being as simple as using something that already exists, in this case we just use the Eater component's built in function to set a function whenever you eat something

-- In your character's master_postinit
inst.components.eater:SetOnEatFn(oneatfn) -- 'oneatfn' can be whatever you want your function to be named

-- Above, outside the postinits
local function oneatfn(inst, food)
  if food.prefab == "myfood" then -- Can also be if food:HasTag("mytag") then
    -- Lessen the bad effects or turn them off here
    end
end

Hope this at least gets you started in the right direction

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