> For the complete documentation index, see [llms.txt](https://wiki.mypet-plugin.de/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.de/legacy/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**.

## Script

### Result Methods

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

* * `function getLevel(exp, mypet)`-> return the actual level in this method.
  * `function getRequiredExp(exp, mypet)` -> return the exp that are needed to levelup in this method
  * `function getCurrentExp(exp, mypet)` -> return the actual exp of the current level in this method.
  * `function getExpByLevel(level, mypet)` -> return the exp needed for this level in this method.

**Usable Methods**

You can use the following methods to react individually on some pets:

* `MyPet.getType()` -> pet-type of the *MyPet*.
* `MyPet.getOwnerName()` -> name of the owner.
* `MyPet.getSkilltree()` -> selected skilltree.
* `MyPet.getUUID()` -> internal UUID of the *MyPet*.
* `MyPet.getWorldGroup()` -> worldgroup the *MyPet* is in.

If you have any questions related to this topic please contact me on Discord or the Spigot forums.

## Examples

You can find a working example [here](https://github.com/xXKeyleXx/MyPet/blob/master/experience-scripts/exp.js) (it calculates it the same way as it was calculated for players in [Minecraft 1.3.1](http://www.minecraftwiki.net/wiki/Experience#Leveling_Up)).


---

# 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 dynamically by asking a question.

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

```
GET https://wiki.mypet-plugin.de/legacy/systems/experience/expjs.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
