> ## Documentation Index
> Fetch the complete documentation index at: https://docs.megaworks.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Config.lua

## Metabolism rates

One of the most important parts of the metabolism script is metabolism rates, they're just a way to configure how fast hunger/thirst etc... will decrease in time.

Here are the main parameters that need to be tweaked:

* `Config.baseRate`: basically tells how much of each metabolism gets decreased at each tick (by default 1s)
* `Config.lowTemperatureRate`: this is how much of metabolism gets decreased if the temperature is low, low temperature affects hunger.
* `Config.highTemperatureRate`: as above, but for hot temperature. Hot temperature affects thirst.
* `Config.walkingRate`: as above, but for walking
* `Config.runningRate`: as above, but for running (walking and running are treated as separated actions, they don't get added up).
* `Config.stomachEmptyingRate`: this is how fast the stomach gets empty, basically it tells how frequently the player can eat again without vomiting because it's full.
* `Config.lowTemperature`: threshold value for low temperature, if the body temperature is below this temperature, it will add the `lowTemperatureRate` debuff.
* `Config.highTemperature`: same as above but inverted, if the body temperature is higher than this temperature, it will add the `highTemperatureRate` debuff.

## How to configure an edible item

First of all edible items are located in the `config.lua` file inside the `Config.nutritionalValues` table, this table holds all the data for the script to add/remove metabolism stats, execute custom actions and potentially trigger diseases.

### Example

Let's say we want to add a new food which is a shrimp 🦐, we want it in two versions: `raw_shrimp` and `cooked_shrimp` so that we can give diseases if eaten raw.

Let's go ahead and write a simple configuration

```lua theme={null}
Config.nutritionalValues = {
    ...
    ['raw_shrimp'] = {
        disease = {
            {
                id = 'dysentery',
                probability = 1.0, -- probability goes from 0 (0%) to 1.0 (100%)
            }
        },
        stats = {
            stomach = 0,
            stamina = -20,
            stress = 50,
            food = 0,
            water = 0,
        },
        onConsume = function()
            Eat() -- trigger the generic eat animation
            Wait(2000) -- wait for 2 seconds
            Vomit() -- trigger the vomit animation
            -- other custom code you may want to add
        end,
    },
    ['cooked_shrimp'] = {
        stats = {
            stomach = 10,
            stamina = 10,
            stress = 0,
            food = 20,
            water = 0,
        },
        onConsume = function()
            Eat() -- trigger the generic eat animation
            -- other custom code you may want to add
        end,
    },
    ...
}
```

It's that simple! You just bound two new items to the metabolism script.
