Anonymous

In-game Functions: Difference between revisions

From Melvor Idle
Update for 1.0.2
m (→‎addMasteryXpToPool: Correct function name)
(Update for 1.0.2)
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{V|1.0}}
{{V|1.0.2}}
In-game functions are responsible for most things in the game. It is possible to interact directly with them through the console. This can be used to add items, levels, GP and more. These functions can be executed though the console. To access the console open Developer Tools (usually by pressing F12) in your browser and navigate to the console. Then, simply paste the code in the input field and press enter. Most functions will require you to fill out variables in the code before executing them. Note that all code is case sensitive.
In-game functions are responsible for most things in the game. It is possible to interact directly with them through the console. This can be used to add items, levels, GP and more. These functions can be executed though the console. To access the console open Developer Tools (usually by pressing F12) in your browser and navigate to the console. Then, simply paste the code in the input field and press enter. Most functions will require you to fill out variables in the code before executing them. Note that all code is case sensitive.


'''Disclaimer:''' Blindly adding items and experience will most likely take away game enjoyment. It is highly encouraged only to use this to either test things or recoup lost items/progress due to lost saves.
'''Disclaimer:''' Blindly adding items and experience will most likely take away game enjoyment. It is highly encouraged only to use this to either test things or recoup lost items/progress due to lost saves.


'''Disclaimer:''' You are playing around with the code of the game if you make mistakes, it is possible that could corrupt your game. It is highly recommended to '''BACKUP YOUR SAVE''' before running any in-game functions.
{| class="warningbox"
| You are playing around with the code of the game if you make mistakes, it is possible that could corrupt your game. It is highly recommended to '''BACKUP YOUR SAVE''' before running any in-game functions.
|}


==Using In-game Functions On Steam==
==Using In-game Functions On Steam==
Players should refer to the [[Scripting and Extensions Instructions#Steam Console and Scripts|Scirpting and Extensions Instructions]] page for a step-by-step guide on using these functions with the Steam version of Melvor Idle.
Players should refer to the [[Scripting and Extensions Instructions#Steam Console and Scripts|Scripting and Extensions Instructions]] page for a step-by-step guide on using these functions with the Steam version of Melvor Idle.


== addItemToBank ==
== addItemToBank ==
Line 44: Line 46:
| itemID || int || No || || The ID of the item.<br />For a complete list of items and their IDs, see: [[Table of Items]]
| itemID || int || No || || The ID of the item.<br />For a complete list of items and their IDs, see: [[Table of Items]]
|-
|-
| deactiveGloves || boolean || Yes || true || If <code>true</code>, the count of glove charges will be set to 0 if the itemID is for a gloves with charges.
| deactiveGloves || boolean || Yes || true || If <code>true</code>, the count of glove charges will be set to 0 if the itemID is for a pair of gloves with charges.
|}
|}


Line 52: Line 54:


== player.addGP ==
== player.addGP ==
The player.addGP function can be used to add gp to a player.
The player.addGP function can be used to add [[Currency#Gold Pieces|GP]] to a player.
  <nowiki>player.addGP(amount, source)</nowiki>
  <nowiki>player.addGP(amount, source)</nowiki>
=== Attributes ===
=== Attributes ===
Line 61: Line 63:
| amount|| int || No || || The quantity of GP to add
| amount|| int || No || || The quantity of GP to add
|-
|-
| source || string || No || || The source of the GP being added. If set to "Combat" it will add the gp to the players gp received in combat stat for tracking.
| source || string || No || || The source of the GP being added. If set to "Combat" it will add the GP to the players "GP received in combat" stat for tracking.
|}
|}
=== Examples ===
=== Examples ===
Line 70: Line 72:


== player.removeGP ==
== player.removeGP ==
The player.removeGP function can be used to remove gp from a player.
The player.removeGP function can be used to remove [[Currency#Gold Pieces|GP]] from a player. If the amount specified is greater than the amount the player currently has, then no GP will be removed.
  <nowiki>player.removeGP(amount)</nowiki>
  <nowiki>player.removeGP(amount)</nowiki>
=== Attributes ===
=== Attributes ===
Line 81: Line 83:
=== Examples ===
=== Examples ===
  <nowiki>player.removeGP(1);</nowiki>
  <nowiki>player.removeGP(1);</nowiki>
The above code will remove 1 gp from the player.
The above code will remove 1 GP from the player.
 
== player.addSlayerCoins ==
The player.addSlayerCoins function can be used to add slayer coins to a player.
<nowiki>player.addSlayerCoins(amount)</nowiki>
=== Attributes ===
{| class="wikitable"
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
| amount || int || No || || The quantity of slayer coins to add. This amount can be increased or decreased if the player is currently affected by any +/-% Slayer coins bonuses.
|}
=== Examples ===
<nowiki>player.addSlayerCoins(1);</nowiki>
The above code will add 1 slayer coin to the player, and update player stats.


== player.addPrayerPoints ==
== player.removeSlayerCoins ==
The player.addPrayerPoints function can be used to add prayer points to a player.
The player.removeSlayerCoins function can be used to remove slayer coins from a player. If the amount specified is greater than the amount the player currently has, then no slayer coins will be removed.
  <nowiki>player.addPrayerPoints(amount)</nowiki>
<nowiki>player.removeSlayerCoins(amount, render)</nowiki>
=== Attributes ===
{| class="wikitable"
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
| amount || int || No || || The quantity of slayer coins to remove
|-
| render || boolean || Yes || true || If <code>true</code>, spawns a notification showing the quantity of coins removed and immediately updates the UI
|}
=== Examples ===
  <nowiki>player.removeSlayerCoins(1);</nowiki>
The above code will remove 1 slayer coin from the player, and immediately update the UI.
 
== updateRaidCoins ==
The updateRaidCoins function can be used to add or remove [[Currency#Raid Coins|raid coins]] from a player.
<nowiki>updateRaidCoins(amount)</nowiki>
=== Attributes ===
=== Attributes ===
{| class="wikitable"
{| class="wikitable"
Line 91: Line 123:
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
|-
| amount|| int || No || || The quantity of prayer points to add.
| amount || int || Yes || 0 || The quantity of raid coins to be added. Coins can also be removed if a negative number is specified.
|}
|}
=== Examples ===
=== Examples ===
  <nowiki>player.addPrayerPoints(1);</nowiki>
  <nowiki>updateRaidCoins(1);</nowiki>
The above code will add 1 prayer point to the player, and update player stats.
The above will add 1 raid coin to the player.


== player.addSlayerCoins ==
== player.addPrayerPoints ==
The player.addSlayerCoins function can be used to add slayer coins to a player.
The player.addPrayerPoints function can be used to add prayer points to a player.
  <nowiki>player.addSlayerCoins(amount)</nowiki>
  <nowiki>player.addPrayerPoints(amount)</nowiki>
=== Attributes ===
=== Attributes ===
{| class="wikitable"
{| class="wikitable"
Line 105: Line 137:
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
|-
| amount|| int || No || || The quantity of slayer coins to add.
| amount || int || No || || The quantity of prayer points to add.
|}
|}
=== Examples ===
=== Examples ===
  <nowiki>player.addSlayerCoins(1);</nowiki>
  <nowiki>player.addPrayerPoints(1);</nowiki>
The above code will add 1 slayer coin to the player, and update player stats.
The above code will add 1 prayer point to the player, and update player stats.


== player.addXP ==
== player.addXP ==
Line 128: Line 160:


== addMasteryXP ==
== addMasteryXP ==
The addMasteryXP function can be used to add experience to any specific Mastery in a skill. Note that the game will not visually show the updated Masterry experience until after refresh or 1 new action.  
The addMasteryXP function can be used to add experience to any specific Mastery in a skill. Note that the game will not visually show the updated Mastery experience until after refresh or 1 new action.  
  <nowiki>addMasteryXP(skillID, masteryID, timePerAction, spendingXP, xp, addToPool, offline)</nowiki>
  <nowiki>addMasteryXP(skillID, masteryID, timePerAction, spendingXP, xp, addToPool, offline)</nowiki>
=== Attributes ===
=== Attributes ===
Line 155: Line 187:
! Skill !! Mastery ID
! Skill !! Mastery ID
|-
|-
| {{Skill|Woodcutting}} || Index of the required tree within the constant <code>trees</code>
| {{Skill|Woodcutting}} || Index of the required tree within the <code>Trees</code> enum
|-  
|-  
| {{Skill|Thieving}} || Index of the required NPC within the constant <code>thievingNPC</code>
| {{Skill|Thieving}} || Index of the required NPC within the <code>ThievingNPCs</code> enum
|-
| {{Skill|Agility}} || Index of the required obstacle within the <code>AgilityObstacles</code> enum
|-
| {{Skill|Astrology}} || Index of the required constellation within the <code>ASTROLOGY</code> constant
|-
|-
| {{Skill|Farming}} || <code>items[itemID].masteryID[1]</code> replacing <code>itemID</code> with the ID of the planted seed
| {{Skill|Farming}} || <code>items[itemID].masteryID[1]</code> replacing <code>itemID</code> with the ID of the planted seed
|-
|-
| {{Skill|Fishing}} || rowspan="9" | <code>items[itemID].masteryID[1]</code>, replacing <code>itemID</code> with the ID of the item produced by the action
| {{Skill|Fishing}} || rowspan="10" | <code>items[itemID].masteryID[1]</code>, replacing <code>itemID</code> with the ID of the item produced by the action
|-
|-
| {{Skill|Firemaking}}
| {{Skill|Firemaking}}
Line 178: Line 214:
|-
|-
| {{Skill|Herblore}}
| {{Skill|Herblore}}
|-
| {{Skill|Summoning}}
|}
|}


Line 187: Line 225:
The above code will result in the calculation & addition of the amount of Mastery XP from an action in skill with ID 2 (Firemaking) for item with Mastery ID 3 (Teak Logs), supposing the action took 3,000 milliseconds.
The above code will result in the calculation & addition of the amount of Mastery XP from an action in skill with ID 2 (Firemaking) for item with Mastery ID 3 (Teak Logs), supposing the action took 3,000 milliseconds.


== addMasteryXpToPool ==
== addMasteryXPToPool ==
The addMasteryXpToPool function can be used to add mastery pool experience to a skill
The addMasteryXpToPool function can be used to add mastery pool experience to a skill
  <nowiki>addMasteryXPToPool(skillID, xp, offline, token)</nowiki>
  <nowiki>addMasteryXPToPool(skillID, xp, offline, token)</nowiki>
Line 204: Line 242:
|}
|}
=== Examples ===
=== Examples ===
  <nowiki>addMasteryXpToPool(11, 600);</nowiki>
  <nowiki>addMasteryXPToPool(11, 600);</nowiki>
The above code will result in 150 Mastery Pool XP being added to the skill with ID 11 (Farming) if the player is under 99 in farming. Or 300 Mastery Pool XP being added if the player is over 99
The above code will result in 150 Mastery Pool XP being added to the skill with ID 11 (Farming) if the player is under 99 in farming. Or 300 Mastery Pool XP being added if the player is over 99
== unlockPet ==
The unlockPet function is used to unlock [[Pets]]. Note that unlocking a pet is permanent - there is no supported method to lock a pet once again.
<nowiki>unlockPet(petID, offline)</nowiki>
=== Attributes ===
{| class="wikitable"
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
| petID || int || No || || The ID of the pet, which can be found on the individual pet pages (such as {{PetIcon|Ty}} for example).
|-
| offline || boolean || Yes || false || Determines if various UI elements are immediately updated to reflect the experience gain. Should usually be left as the default value
|}
=== Examples ===
<nowiki>unlockPet(4);</nowiki>
The above code will result in the unlocking of {{PetIcon|Cool Rock}}.


== Reference Tables ==
== Reference Tables ==