# 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="https://3719360761-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fck7Fdkl3tw9GlGnkwHuu%2Fuploads%2FkOuCEYNEwClLBEtCiSDy%2F2BCQFyo.png?alt=media&#x26;token=dc735a8a-0e85-4afe-ab76-227253966d23" 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="https://3719360761-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fck7Fdkl3tw9GlGnkwHuu%2Fuploads%2FRalyvO794ZXKiuPZlNvv%2FyZMEdHM.png?alt=media&#x26;token=2252974d-e865-449a-bda8-b4e5ad940c0a" 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>
