In-game Functions: Difference between revisions

From Melvor Idle
mNo edit summary
(→‎Remove Item from Bank: Document solution for removing items with invalid quantities)
 
(17 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{V|1.0.1}}
{{V|1.1.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.
<div class="warningbox">You are playing around with the code of the game, as such 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.</div>


==Using In-game Functions On Steam==
==Using In-game Functions On Steam, Android, or iOS==
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.
Players can use the [https://mod.io/g/melvoridle/m/devconsole dev.Console mod] to execute these commands within the Steam, Android, and iOS versions of Melvor Idle.


== addItemToBank ==
== Add Item to Bank ==
The addItemToBank function can be used to add any item in the game to the bank.
The addItemByID function can be used to add any item in the game to the bank.
  <nowiki>addItemToBank(itemID, quantity, found, showNotification, ignoreBankSpace)</nowiki>
  <syntaxhighlight lang="js">game.bank.addItemByID(itemID, quantity, logLost, found, ignoreSpace)</syntaxhighlight>


=== Attributes ===
=== Attributes ===
Line 18: Line 18:
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
|-
| itemID || int || No || || The ID of the item.<br />For a complete list of items and their IDs, see: [[Table of Items]]
| itemID || string || No || || The ID of the item.<br />For a complete list of items and their IDs, see: [[Table of Items]]
|-
|-
| quantity || int || No || || Quantity of item to add. Will remove items from the bank if a negative value is specified
| quantity || int || No || || Quantity of item to add.
|-
|-
| found || boolean || Yes || true || Determines if it will show in item completion log
| logLost || boolean || Yes || false || If <code>true</code>, items that did not fit into the bank will be logged as lost
|-
|-
| showNotification || boolean || Yes || true || Determines if it will show notification
| found || boolean || Yes || false || Determines if items added by this function will be included within the "Times Found" statistic for that item within the completion log. Therefore, unless this parameter is set to <code>true</code>, any items added in this way will not contribute towards the player's item completion percentage.
<br/><br/>{{Disclaimer|'''Note:''' When adding {{ItemIcon|Bank Slot Token|Bank Slot Tokens}}, it is suggested that this parameter is set to <code>true</code>, otherwise this may cause issues with the way the game calculates the amount of bank space a player has.}}
|-
|-
| ignoreBankSpace || boolean || Yes || false || If <code>true</code>, the item will be added to the bank even if the bank is already full
| ignoreSpace || boolean || Yes || false || If <code>true</code>, the item will be added to the bank even if the bank is already full
|}
|}


=== Examples ===
=== Examples ===
  <nowiki>addItemToBank(1, 10, false);</nowiki>
  <syntaxhighlight lang="js">game.bank.addItemByID("melvorD:Oak_Logs", 10, true, true, false);</syntaxhighlight>
The above code will result in 10 items with item ID 1 (Oak Logs) being added to the Bank without them appearing in the item completion log, but with notification.
The above code will result in attempting to add 10 {{ItemIcon|Oak Logs}} to the Bank. If they do not fit, 10 will be added to the # of Oak Logs lost on the item's stats. Additionally, Oak Logs will be marked as discovered in the Completion Log.


== removeItemFromBank ==
== Remove Item from Bank ==
The removeItemFromBank function can be used to remove any item from the bank
The removeItemQuantityByID function can be used to remove any item from the bank
  <nowiki>removeItemFromBank(itemID, deactiveGloves)</nowiki>
  <syntaxhighlight lang="js">game.bank.removeItemQuantityByID(itemID, quantity, removeItemCharges)</syntaxhighlight>
 
Note that if an item's quantity is in an invalid state, such as <syntaxhighlight lang="js" inline>NaN</syntaxhighlight> or <syntaxhighlight lang="js" inline>Infinity</syntaxhighlight>, then this function will not be able to remove that item from the bank. For any such items, use the below snippet instead:
{{SpoilerBox
|color=default
|title=Code
|text=First, enter the below into the console:
<syntaxhighlight lang="js">function removeItemByID(itemID) {
const item = game.items.getObjectByID(itemID);
if (item === undefined)
throw new Error(
`Error removing item from bank by id. Item with id: ${ itemID } is not registered.`
);
const bankItem = game.bank.items.get(item);
if (bankItem === undefined)
throw new Error(
`Tried to remove quantity from bank, but item is not in bank.`
);
bankItem.quantity = 1;
game.bank.removeItemQuantity(item, 1, true);
}</syntaxhighlight>
After this, invoke the newly-created function with the appropriate item ID to remove items from the bank. For example: <syntaxhighlight lang="js" inline>removeItemByID('melvorD:Oak_Logs');</syntaxhighlight>
}}


=== Attributes ===
=== Attributes ===
Line 42: Line 65:
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
|-
| itemID || int || No || || The ID of the item.<br />For a complete list of items and their IDs, see: [[Table of Items]]
| itemID || string || 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.
| quantity || int || No || || The number of items to remove.
|-
| removeItemCharges || 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.
|}
|}


=== Examples ===
=== Examples ===
  <nowiki>removeItemFromBank(1);</nowiki>
  <syntaxhighlight lang="js">game.bank.removeItemQuantityByID('melvorD:Oak_Logs', 10);</syntaxhighlight>
The above code will result in item ID 1 (Oak Logs) being removed from the bank.
The above code will result in 10 {{ItemIcon|Oak Logs}} being removed from the bank.


== player.addGP ==
== Adjust Currencies (GP, Slayer Coins, and Raid Coins) ==
The player.addGP function can be used to add gp to a player.
All [[Currency]] within the game, being {{GP}} [[GP]], {{SC}} [[Slayer Coins]] (SC), and {{RC}} [[Raid Coins]] (RC) can be adjusted using the same set of functions:
  <nowiki>player.addGP(amount, source)</nowiki>
* To adjust GP, use <syntaxhighlight lang="js" inline>game.gp</syntaxhighlight>
=== Attributes ===
* To adjust SC, use <syntaxhighlight lang="js" inline>game.slayerCoins</syntaxhighlight>
* To adjust RC, use <syntaxhighlight lang="js" inline>game.raidCoins</syntaxhighlight>
 
=== Add Currency ===
The game.''currency''.add function can be used to add to the player's current balance of that currency.
  <syntaxhighlight lang="js">game.<currency>.add(amount)</syntaxhighlight>
 
==== Attributes ====
{| class="wikitable"
{| class="wikitable"
|-
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
|-
| amount|| int || No || || The quantity of GP to add
| amount || int || No || || The amount to increase the specified currency's balance by
|-
| 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 ===
<nowiki>player.addGP(1,"");</nowiki>
The above code will add 1 gp to the player, and not place the info into the players stats for tracking.
<nowiki>player.addGP(1,"Combat");</nowiki>
The above code will add 1 gp to the player, and place the info into the players stats for tracking.


== player.removeGP ==
==== Examples ====
The player.removeGP function can be used to remove gp from a player.
<nowiki>game.gp.add(1);</nowiki>
  <nowiki>player.removeGP(amount)</nowiki>
The above code will add 1 [[Currency#Gold Pieces|GP]] to the player.
=== Attributes ===
 
=== Remove Currency ===
The game.''currency''.remove function can be used to subtract from the player's current balance of that currency. If the amount specified is greater than the amount the player currently has, then the currency's balance will become negative.
  <syntaxhighlight lang="js">game.<currency>.remove(amount)</syntaxhighlight>
 
==== Attributes ====
{| class="wikitable"
{| class="wikitable"
|-
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
|-
| amount|| int || No || || The quantity of GP to remove
| amount || int || No || || The quantity to decrease the specified currency's balance by
|}
|}
=== Examples ===
<nowiki>player.removeGP(1);</nowiki>
The above code will remove 1 gp from the player.


== player.addPrayerPoints ==
==== Examples ====
The player.addPrayerPoints function can be used to add prayer points to a player.
<syntaxhighlight lang="js">game.raidCoins.remove(1);</syntaxhighlight>
  <nowiki>player.addPrayerPoints(amount)</nowiki>
The above code will remove 1 [[Raid Coins|Raid Coin]] from the player.
=== Attributes ===
 
=== Set Currency ===
The game.''currency''.set function can be used to set the player's balance of that currency to the specified amount. This function may be of particular use to players who have inadvertently found their GP or SC balance is set to an invalid value such as <code>NaN</code>.
  <syntaxhighlight lang="js">game.<currency>.set(amount)</syntaxhighlight>
 
==== Attributes ====
{| class="wikitable"
{| class="wikitable"
|-
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
|-
| amount|| int || No || || The quantity of prayer points to add.
| amount || int || No || || The amount to set the specified currency's balance to
|}
|}
=== Examples ===
<nowiki>player.addPrayerPoints(1);</nowiki>
The above code will add 1 prayer point to the player, and update player stats.


== player.addSlayerCoins ==
==== Examples ====
The player.addSlayerCoins function can be used to add slayer coins to a player.
<syntaxhighlight lang="js">game.slayerCoins.set(999);</syntaxhighlight>
  <nowiki>player.addSlayerCoins(amount)</nowiki>
The above code will set the player's [[Raid Coins|Raid Coin]] balance to 999, regardless of what the previous balance of raid coins owned was.
 
== Add Prayer Points ==
The combat.player.addPrayerPoints function can be used to add prayer points to a player.
  <syntaxhighlight lang="js">game.combat.player.addPrayerPoints(amount)</syntaxhighlight>
=== Attributes ===
=== Attributes ===
{| class="wikitable"
{| class="wikitable"
Line 105: Line 138:
! 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>
  <syntaxhighlight lang="js">game.combat.player.addPrayerPoints(1);</syntaxhighlight>
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 ==
== Add XP ==
The player.addXP function can be used to add experience to any skill. Note that the game will not visually show the updated XP until after refresh or 1 new action.
The addXP function can be used to add experience to any skill.
  <nowiki>player.addXP(skillID, xp)</nowiki>
  <syntaxhighlight lang="js">game.skill.addXP(xp)</syntaxhighlight>
where <code>skill</code> is the lowercase name of the skill you are adding experience to.
=== Attributes ===
=== Attributes ===
{| class="wikitable"
{| class="wikitable"
Line 119: Line 153:
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
|-
| skillID || int || No || || The ID of the skill, see: [[#Skill ID|Skill ID]]
| xp || int || No || || Amount of experience to add.
|-
| xp || int || No || || Amount of experience to add. Note that this is the amount of experience added before bonuses such as that from the {{ItemIcon|Firemaking Skillcape}} or {{PetIcon|Pyro}}
|}
|}
=== Examples ===
=== Examples ===
  <nowiki>player.addXP(10, 1000);</nowiki>
  <syntaxhighlight lang="js">game.thieving.addXP(1000);</syntaxhighlight>
The above code will result in 1000 experience being added to the skill with ID 10 (Thieving).
The above code will result in 1000 experience being added to {{Skill|Thieving}}.


== addMasteryXP ==
== Add Mastery XP ==
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 {{Icon|Mastery}} in a skill.
  <nowiki>addMasteryXP(skillID, masteryID, timePerAction, spendingXP, xp, addToPool, offline)</nowiki>
  <syntaxhighlight lang="js">game.skill.addMasteryXP(masteryAction, xp)</syntaxhighlight>
where <code>skill</code> is the lowercase name of the skill you are adding mastery experience to.
=== Attributes ===
=== Attributes ===
{| class="wikitable"
{| class="wikitable"
Line 135: Line 168:
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
|-
| skillID || int || No || || The ID of the skill, see: [[#Skill ID|Skill ID]]
| masteryAction || object || No || || The action to add Mastery XP to. Obtained with <syntaxhighlight lang="js" inline>game.skill.actions.getObjectByID(id)</syntaxhighlight> where <code>skill</code> is to be replaced with the name of the skill (all lowercase), and <code>id</code> is the ID of the action.
 
A list of action IDs can be obtained by entering the following into the console: <syntaxhighlight lang="js" inline>console.log(game.skill.actions.allObjects.map((a) => a.id + ' - ' + a.name).join('\n'))</syntaxhighlight>.
|-
|-
| masteryID || int || No || || The skill specific Mastery ID. See [[#Mastery IDs|below]] for information on how to identify Mastery ID values
| xp || int || Yes || 0 || Amount of experience to add.
|-
| timePerAction || int || No || || The interval (in milliseconds) of the action granting mastery experience. Has no effect on the result if <code>spendingXP</code> is <code>true</code>
|-
| spendingXP || boolean || Yes || false || <code>true</code>: The amount of experience specified with <code>xp</code> is added, <code>timePerAction</code> is ignored<br /><code>false</code>: The amount of experience added is determined by the [[Mastery#Earning Mastery XP|Mastery experience per action calculation]], <code>xp</code> is ignored
|-
| xp || int || Yes || 0 || Amount of experience to add. Has no effect on the result if <code>spendingXP</code> is <code>false</code>
|-
| addToPool || boolean || Yes || true || Determines whether a portion of the specified experience amount is added to the mastery pool for the relevant skill or not
|-
| 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
|}
=== Mastery IDs ===
Below is a reference of how the various mastery ID values may be identified.
{| class="wikitable"
|-
! Skill !! Mastery ID
|-
| {{Skill|Woodcutting}} || Index of the required tree within the constant <code>trees</code>
|-
| {{Skill|Thieving}} || Index of the required NPC within the constant <code>thievingNPC</code>
|-
| {{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|Firemaking}}
|-
| {{Skill|Cooking}}
|-
| {{Skill|Mining}}
|-
| {{Skill|Smithing}}
|-
| {{Skill|Fletching}}
|-
| {{Skill|Crafting}}
|-
| {{Skill|Runecrafting}}
|-
| {{Skill|Herblore}}
|}
|}


=== Examples ===
=== Examples ===
  <nowiki>addMasteryXP(11, 13, 0, true, 300);</nowiki>
  <syntaxhighlight lang="js">game.farming.addMasteryXP(game.farming.actions.getObjectByID('melvorD:Carrot'), 300);</syntaxhighlight>
The above code will result in 300 Mastery XP being added to the skill with ID 11 (Farming) for Mastery ID 13 (Carrot Seeds).
The above code will result in 300 {{Icon|Mastery}} XP being added to {{Skill|Farming}} for {{ItemIcon|Carrot Seeds}}.


  <nowiki>addMasteryXP(2, 3, 3000);</nowiki>
  <syntaxhighlight lang="js">game.firemaking.addMasteryXP(game.firemaking.actions.getObjectByID('melvorD:Teak_Logs'), 3000);</syntaxhighlight>
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 3,000 {{Icon|Mastery}} XP being added to {{Skill|Firemaking}} for {{ItemIcon|Teak Logs}}.


== addMasteryXPToPool ==
== Add Mastery XP to Pool==
The addMasteryXpToPool function can be used to add mastery pool experience to a skill
The addMasteryPoolXP function can be used to add [[Mastery#The_Mastery_Pool|Mastery Pool]] experience to a skill
  <nowiki>addMasteryXPToPool(skillID, xp, offline, token)</nowiki>
  <syntaxhighlight lang="js">game.skill.addMasteryPoolXP(xp)</syntaxhighlight>
where <code>skill</code> is the lowercase name of the skill you are adding mastery experience to.
=== Attributes ===
=== Attributes ===
{| class="wikitable"
{| class="wikitable"
Line 195: Line 191:
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
|-
| skillID || int || No || || The ID of the skill, see: [[#Skill ID|Skill ID]]
| xp || int || Yes || 0 || Amount of experience to add.
|-
| xp || int || Yes || 0 || Amount of experience to add. One quarter of this value will be added if the player is under level 99 in that skill. One half of the value will be added if the player is level 99 in that skill.
|-
| 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
|-
| token || boolean || Yes || false || Forces forces 100% of the <code>xp</code> value to be added to the pool, ignoring player's level within the skill.
|}
|}
=== Examples ===
=== Examples ===
  <nowiki>addMasteryXPToPool(11, 600);</nowiki>
  <syntaxhighlight lang="js">game.woodcutting.addMasteryPoolXP(600);</syntaxhighlight>
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 600 [[Mastery#The_Mastery_Pool|Mastery Pool]] XP being added to {{Skill|Woodcutting}}.


== unlockPet ==
== Unlock Pet ==
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.
The petManager.unlockPetByID 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>
  <syntaxhighlight lang="js">game.petManager.unlockPetByID(petID)</syntaxhighlight>
=== Attributes ===
=== Attributes ===
{| class="wikitable"
{| class="wikitable"
Line 215: Line 205:
! Attribute !! Type !! Optional? !! Default Value !! Description
! 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).
| petID || string || 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 ===
=== Examples ===
  <nowiki>unlockPet(4);</nowiki>
  <syntaxhighlight lang="js">game.petManager.unlockPetByID('melvorD:CoolRock');</syntaxhighlight>
The above code will result in the unlocking of {{PetIcon|Cool Rock}}.
The above code will result in the unlocking of {{PetIcon|Cool Rock}}.


== Reference Tables ==
== Discover Mark ==
=== Skill ID ===
The discoverMark function is used to discover [[Summoning#Summoning Marks|Summoning Marks]]. Once discovered, there is no supported method to allow a mark to become undiscovered again.
{| class="wikitable sortable"
<syntaxhighlight lang="js">game.summoning.discoverMark(mark)</syntaxhighlight>
=== Attributes ===
{| class="wikitable"
|-
|-
! ID !! Skill
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
|-
| 0 || {{Skill|Woodcutting}}
| mark || object || No || || The mark to discover. Obtained with <syntaxhighlight lang="js" inline>game.summoning.actions.getObjectByID(markID)</syntaxhighlight> where <code>markID</code> is the ID of the mark.
|-
 
| 1 || {{Skill|Fishing}}
A list of mark IDs can be obtained by entering the following into the console: <syntaxhighlight lang="js" inline>console.log(game.summoning.actions.allObjects.map((a) => a.id + ' - ' + a.name).join('\n'))</syntaxhighlight>.
|-
| 2 || {{Skill|Firemaking}}
|-
| 3 || {{Skill|Cooking}}
|-
| 4 || {{Skill|Mining}}
|-
| 5 || {{Skill|Smithing}}
|-
| 6 || {{Skill|Attack}}
|-
| 7 || {{Skill|Strength}}
|-
| 8 || {{Skill|Defence}}
|-
| 9 || {{Skill|Hitpoints}}
|-
| 10 || {{Skill|Thieving}}
|-
| 11 || {{Skill|Farming}}
|-
| 12 || {{Skill|Ranged}}
|-
| 13 || {{Skill|Fletching}}
|-
| 14 || {{Skill|Crafting}}
|-
| 15 || {{Skill|Runecrafting}}
|-
| 16 || {{Skill|Magic}}
|-
| 17 || {{Skill|Prayer}}
|-
| 18 || {{Skill|Slayer}}
|-
| 19 || {{Skill|Herblore}}
|-
| 20 || {{Skill|Agility}}
|-
| 21 || {{Skill|Summoning}}
|-
|22 || {{Skill|Astrology}}
|}
|}
=== Examples ===
<syntaxhighlight lang="js">game.summoning.discoverMark(game.summoning.actions.getObjectByID('melvorF:Dragon'));</syntaxhighlight>
The above code discovers a single mark for the {{ItemIcon|Dragon}} familiar.
{{Menu}}

Latest revision as of 15:46, 8 April 2024

This page was last updated for (v1.1.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.

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.

You are playing around with the code of the game, as such 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, Android, or iOS

Players can use the dev.Console mod to execute these commands within the Steam, Android, and iOS versions of Melvor Idle.

Add Item to Bank

The addItemByID function can be used to add any item in the game to the bank.

game.bank.addItemByID(itemID, quantity, logLost, found, ignoreSpace)

Attributes

Attribute Type Optional? Default Value Description
itemID string No The ID of the item.
For a complete list of items and their IDs, see: Table of Items
quantity int No Quantity of item to add.
logLost boolean Yes false If true, items that did not fit into the bank will be logged as lost
found boolean Yes false Determines if items added by this function will be included within the "Times Found" statistic for that item within the completion log. Therefore, unless this parameter is set to true, any items added in this way will not contribute towards the player's item completion percentage.

Note: When adding Bank Slot Tokens, it is suggested that this parameter is set to true, otherwise this may cause issues with the way the game calculates the amount of bank space a player has.
ignoreSpace boolean Yes false If true, the item will be added to the bank even if the bank is already full

Examples

game.bank.addItemByID("melvorD:Oak_Logs", 10, true, true, false);

The above code will result in attempting to add 10 Oak Logs to the Bank. If they do not fit, 10 will be added to the # of Oak Logs lost on the item's stats. Additionally, Oak Logs will be marked as discovered in the Completion Log.

Remove Item from Bank

The removeItemQuantityByID function can be used to remove any item from the bank

game.bank.removeItemQuantityByID(itemID, quantity, removeItemCharges)

Note that if an item's quantity is in an invalid state, such as NaN or Infinity, then this function will not be able to remove that item from the bank. For any such items, use the below snippet instead:

Code
First, enter the below into the console:
function removeItemByID(itemID) {
	const item = game.items.getObjectByID(itemID);
	if (item === undefined)
	throw new Error(
	`Error removing item from bank by id. Item with id: ${ itemID } is not registered.`
	);
	const bankItem = game.bank.items.get(item);
	if (bankItem === undefined)
	throw new Error(
	`Tried to remove quantity from bank, but item is not in bank.`
	);
	bankItem.quantity = 1;
	game.bank.removeItemQuantity(item, 1, true);
}

After this, invoke the newly-created function with the appropriate item ID to remove items from the bank. For example: removeItemByID('melvorD:Oak_Logs');

Attributes

Attribute Type Optional? Default Value Description
itemID string No The ID of the item.
For a complete list of items and their IDs, see: Table of Items
quantity int No The number of items to remove.
removeItemCharges boolean Yes true If true, the count of glove charges will be set to 0 if the itemID is for a pair of gloves with charges.

Examples

game.bank.removeItemQuantityByID('melvorD:Oak_Logs', 10);

The above code will result in 10 Oak Logs being removed from the bank.

Adjust Currencies (GP, Slayer Coins, and Raid Coins)

All Currency within the game, being GP GP, SC Slayer Coins (SC), and RC Raid Coins (RC) can be adjusted using the same set of functions:

  • To adjust GP, use game.gp
  • To adjust SC, use game.slayerCoins
  • To adjust RC, use game.raidCoins

Add Currency

The game.currency.add function can be used to add to the player's current balance of that currency.

game.<currency>.add(amount)

Attributes

Attribute Type Optional? Default Value Description
amount int No The amount to increase the specified currency's balance by

Examples

game.gp.add(1);

The above code will add 1 GP to the player.

Remove Currency

The game.currency.remove function can be used to subtract from the player's current balance of that currency. If the amount specified is greater than the amount the player currently has, then the currency's balance will become negative.

game.<currency>.remove(amount)

Attributes

Attribute Type Optional? Default Value Description
amount int No The quantity to decrease the specified currency's balance by

Examples

game.raidCoins.remove(1);

The above code will remove 1 Raid Coin from the player.

Set Currency

The game.currency.set function can be used to set the player's balance of that currency to the specified amount. This function may be of particular use to players who have inadvertently found their GP or SC balance is set to an invalid value such as NaN.

game.<currency>.set(amount)

Attributes

Attribute Type Optional? Default Value Description
amount int No The amount to set the specified currency's balance to

Examples

game.slayerCoins.set(999);

The above code will set the player's Raid Coin balance to 999, regardless of what the previous balance of raid coins owned was.

Add Prayer Points

The combat.player.addPrayerPoints function can be used to add prayer points to a player.

game.combat.player.addPrayerPoints(amount)

Attributes

Attribute Type Optional? Default Value Description
amount int No The quantity of prayer points to add.

Examples

game.combat.player.addPrayerPoints(1);

The above code will add 1 prayer point to the player, and update player stats.

Add XP

The addXP function can be used to add experience to any skill.

game.skill.addXP(xp)

where skill is the lowercase name of the skill you are adding experience to.

Attributes

Attribute Type Optional? Default Value Description
xp int No Amount of experience to add.

Examples

game.thieving.addXP(1000);

The above code will result in 1000 experience being added to Thieving.

Add Mastery XP

The addMasteryXP function can be used to add experience to any specific Mastery in a skill.

game.skill.addMasteryXP(masteryAction, xp)

where skill is the lowercase name of the skill you are adding mastery experience to.

Attributes

Attribute Type Optional? Default Value Description
masteryAction object No The action to add Mastery XP to. Obtained with game.skill.actions.getObjectByID(id) where skill is to be replaced with the name of the skill (all lowercase), and id is the ID of the action.

A list of action IDs can be obtained by entering the following into the console: console.log(game.skill.actions.allObjects.map((a) => a.id + ' - ' + a.name).join('\n')).

xp int Yes 0 Amount of experience to add.

Examples

game.farming.addMasteryXP(game.farming.actions.getObjectByID('melvorD:Carrot'), 300);

The above code will result in 300 Mastery XP being added to Farming for Carrot Seeds.

game.firemaking.addMasteryXP(game.firemaking.actions.getObjectByID('melvorD:Teak_Logs'), 3000);

The above code will result in 3,000 Mastery XP being added to Firemaking for Teak Logs.

Add Mastery XP to Pool

The addMasteryPoolXP function can be used to add Mastery Pool experience to a skill

game.skill.addMasteryPoolXP(xp)

where skill is the lowercase name of the skill you are adding mastery experience to.

Attributes

Attribute Type Optional? Default Value Description
xp int Yes 0 Amount of experience to add.

Examples

game.woodcutting.addMasteryPoolXP(600);

The above code will result in 600 Mastery Pool XP being added to Woodcutting.

Unlock Pet

The petManager.unlockPetByID function is used to unlock Pets. Note that unlocking a pet is permanent - there is no supported method to lock a pet once again.

game.petManager.unlockPetByID(petID)

Attributes

Attribute Type Optional? Default Value Description
petID string No The ID of the pet, which can be found on the individual pet pages (such as Ty for example).

Examples

game.petManager.unlockPetByID('melvorD:CoolRock');

The above code will result in the unlocking of Cool Rock.

Discover Mark

The discoverMark function is used to discover Summoning Marks. Once discovered, there is no supported method to allow a mark to become undiscovered again.

game.summoning.discoverMark(mark)

Attributes

Attribute Type Optional? Default Value Description
mark object No The mark to discover. Obtained with game.summoning.actions.getObjectByID(markID) where markID is the ID of the mark.

A list of mark IDs can be obtained by entering the following into the console: console.log(game.summoning.actions.allObjects.map((a) => a.id + ' - ' + a.name).join('\n')).

Examples

game.summoning.discoverMark(game.summoning.actions.getObjectByID('melvorF:Dragon'));

The above code discovers a single mark for the Dragon familiar.