> For the complete documentation index, see [llms.txt](https://wiki.mypet-plugin.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.mypet-plugin.com/mypet-3/systems/experience/expjs.md).

# Experience-Script

With the **Experience-Script** `exp.js` it's possible to customize when a pet will level up. As you can see at the file ending, the used language is **JavaScript**.

## Installation

1. Download [Rhino](https://github.com/mozilla/rhino/releases), rename the jar to `rhino.jar` and put the file into the MyPet folder.
2. Set `LevelSystem.CalculationMode` to **`JavaScript`** int the **`config.yml`.**
3. Edit the `exp.js` to your likings.

## Script

To make a fully functional exp-script that can be used by *MyPet* you have to implement the following method:

{% code title="exp.js" %}

```javascript
function getExpByLevel(level, petType, worldGroup) {
  var exp = 0;
  return exp;
}
```

{% endcode %}

### **Differentiating between pet types and world groups**

Examples:

{% tabs %}
{% tab title="Pet Type" %}
{% code title="exp.js" %}

```javascript
function getExpByLevel(level, petType, worldGroup) {
  var exp = 10;
  if(petType == "Cow") {
    exp = 15;
  }
  return exp;
}
```

{% endcode %}
{% endtab %}

{% tab title="World Group" %}
{% code title="exp.js" %}

```javascript
function getExpByLevel(level, petType, worldGroup) {
  var exp = 10;
  if(worldGroup == "LuckyWorlds") {
    exp = 20;
  }
  return exp;
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Debugging

To provide an easy method to debug your scripts the plugin adds a print method to the usable JavaScript functions.

```javascript
print("message");
```

## Example

{% code title="exp.js" %}

```javascript
//  Level 2-17 cost 17 XP points each
//  Level 18-31 cost 3 more XP points than the previous
//  Level 32-∞ cost 7 more XP points than the previous

function getExpByLevel(level, petType, worldGroup) {
    var exp = 0, i;
    if (level > 31) {
        exp = 887;
        level -= 31;
        for (i = 1; i < level; i++) {
            exp += 62 + (i * 7);
        }
        return exp;
    }
    if (level > 17) {
        exp = 272;
        level -= 17;
        for (i = 1; i <= level; i++) {
            exp += 17 + (i * 3);
        }
        return exp;
    }
    return (level - 1) * 17;
}
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://wiki.mypet-plugin.com/mypet-3/systems/experience/expjs.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
