# Adding medications

*Advanced Roleplay Environment supports modular medications. This means you can easily add medications or edit them accordingly.*

## Adding medications

In order to add a medication we just need to add the medication inside the medications file and configure the properties accordingly.

### Adding the medication

Since all medications are saved inside <mark style="color:yellow;">`script/entities/medications.lua`</mark>, we will open this file. This should look like this:

<figure><img src="/files/BzjbdkXNNbfmQ8my4zL8" alt=""><figcaption><p>script/entities/medications.lua</p></figcaption></figure>

Now we will scroll to the bottom and just copy a medication from above and edit it to our needs so it should look like this:

<figure><img src="/files/4aBtMtDj8Ov7nlbpIl1Y" alt=""><figcaption><p>script/entities/medications.lua</p></figcaption></figure>

### Configuring the medication

There are many options available for us to configure the medication perfectly to our needs.

<table><thead><tr><th width="248.33333333333331">Option</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td>painReduce</td><td>This property is a number and contains the value of how much the pain get reduced.</td><td><code>painReduce = 0.3</code><br>The pain get reduced by 0.3 * <code>effectRatio</code> per second.</td></tr><tr><td>hrIncreaseLow</td><td>This property is a table contains a table { minIncrease, maxIncrease } how much the heart rate will increase or decrease if the heart rate is below 55 bpm. </td><td><code>hrIncreaseLow = { -10, 10 }</code><br>The heart rate will in minimum decrease by 10 or in maximum increase by 10 if the heart rate is below 55 bpm.</td></tr><tr><td>hrIncreaseNormal</td><td>This property is a table contains a table { minIncrease, maxIncrease } how much the heart rate will increase or decrease if the heart rate is >= 55 bpm and &#x3C;= 110 bpm.</td><td><code>hrIncreaseNormal = { 5, 20 }</code> <br>The heart rate will in minimum increase by 5 and in maximum by 20 if the heart rate is >= 55 bpm and &#x3C;= 110 bpm.</td></tr><tr><td>hrIncreaseHigh</td><td>This property is a table contains a table { minIncrease, maxIncrease } how much the heart rate will increase or decrease if the heart rate is > 110 bpm</td><td><code>hrIncreaseHigh = { 2, 7 }</code><br>The heart rate will in minimum increase by 2 and in maximum by 7 if the heart rate is above 110 bpm.</td></tr><tr><td>timeInSystem (maxTimeInSystem)</td><td>This property is a number and contains the value how long a medication is kept in the system before removing it. Also it will be used to calculate the effect ratio. (in seconds)</td><td><code>timeInSystem = 1800</code><br>The medication is kept 1800 seconds in system before removing it.<br><br>Calculation for the effect ratio: <br><code>effectRatio = min((timeInSystem / timeTillMaxEffect) ^ 2, 1) * (maxTimeInSystem - timeInSystem) / maxTimeInSystem</code><br><br>To understand the effect ratio formula we need to define the values where:<br> - timeInSystem is variable and describes the current time in the system in seconds.<br> - timeTillMaxEffect is a constant and describes the time till the effect ratio reaches 1.<br> - maxTimeInSystem is a constant and describes how long the medication will stay in the system until it reaches 0.0 effect ratio at the end.<br> - min(valueA, valueB) will always return the lowest value of both so if valueA is 5 and valueB is 8 it will return 5. In our example it is a calculation and 1 so it will always be less &#x3C;= 1.</td></tr><tr><td>timeTillMaxEffect</td><td>This property is a number and contains the value when the max effect ratio is reached. (in seconds)</td><td><code>timeTillMaxEffect = 30</code><br>The medication will reach its max effect after 30 seconds so a effect ratio of 1.</td></tr><tr><td>maxDose</td><td>This property is a number and contains the value after how many medications in system the function <code>onOverDose</code> will be triggered.</td><td><code>maxDose = 5</code><br>The property onOverDose will be triggered after 5 times of injection of this medication.</td></tr><tr><td>onOverDose</td><td>This property is a function and will be triggered if the number of the same medication in the system is >= <code>maxDose</code></td><td><code>onOverDose = function()</code> <br>    <code>print("hello!")</code><br><code>end</code><br>The function will print "hello" after this function has been triggered.</td></tr><tr><td>viscosityChange</td><td>The viscosity of a fluid is a measure of its resistance to gradual deformation by shear stress or tensile stress. For liquids, it corresponds to the informal concept of "thickness". This value will increase/decrease the viscoty of the blood with the percentage given. Where 100 = max. Using the minus will decrease viscosity.</td><td><code>viscosityChange = -10</code><br>The peripheral resistance will reduce by maximum 10 and <code>viscosityChange * effectRatio</code> per second.</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.veryinsanee.space/advanced-roleplay-environment/guides/advanced-configuration-guide/adding-medications.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
