Anonymous

In-game Functions: Difference between revisions

From Melvor Idle
m
Tags: Mobile edit Mobile web edit
Line 162: Line 162:
The first line will add 1 prayer point to the player while the second will remove 50 soul points.
The first line will add 1 prayer point to the player while the second will remove 50 soul points.


== Add or Remove XP or Abyssal XP ==
== Add, Remove or Set XP or Abyssal XP ==
The <code>addXP</code> and <code>addAbyssalXP</code> functions can be used to add experience and abyssal experience to any skill.
The <code>addXP</code> and <code>addAbyssalXP</code> functions can be used to add or remove experience and abyssal experience from any skill. The <code>setXP</code> and <code>setAbyssalXP</code> can be used to set the new experience or abyssal experience value.
  <syntaxhighlight lang="js">
  <syntaxhighlight lang="js">
game.<skill>.addXP(xp);
game.<skill>.addXP(xp);
game.<skill>.addAbyssalXP(xp);
game.<skill>.addAbyssalXP(xp);
game.<skill>.setXP(xp);
game.<skill>.setAbyssalXP(xp);
</syntaxhighlight>
</syntaxhighlight>
where <code><skill></code> is the lowercase name of the skill you are adding experience to.
where <code><skill></code> is the lowercase name of the skill you are adding experience to.
Line 174: Line 176:
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
|-
| xp || int || No || || Amount of experience to add. A negative value will remove experience.
| xp || int || No || || Amount of experience to add. A negative number will remove experience. When removing XP, it's best to use the Set commands as these will also visually update your current level if the removed experience results in a lower level.
|}
|}
=== Examples ===
=== Examples ===
  <syntaxhighlight lang="js">
  <syntaxhighlight lang="js">
game.thieving.addXP(1000);
game.thieving.addXP(1000);
game.thieving.addAbyssalXP(-700);
game.astrology.setAbyssalXP(game.astrology._abyssalXP - 700);
game.attack.setXP(game.attack._xp - 2500);
</syntaxhighlight>
</syntaxhighlight>
The first line will result in 1000 experience being added to {{Skill|Thieving}} while the second line will remove 700 abyssal xp from Thieving.
The first line will result in 1,000 experience being added to {{Skill|Thieving}}. The second line will remove 700 abyssal xp from Astrology. The third line will remove 2,500 experience from Attack.


== Add or Remove Mastery XP ==
== Add or Remove Mastery XP ==