In-game Functions: Difference between revisions

From Melvor Idle
(Bump version to 1.1.2 & add standard navigation)
(Document additional currency function & consolidate all currencies into their own section)
Line 6: Line 6:
<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>
<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 can use the [https://mod.io/g/melvoridle/m/devconsole dev.Console mod] to execute these commands within 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.


== Add Item to Bank ==
== Add Item to Bank ==
Line 53: Line 53:
The above code will result in 10 {{ItemIcon|Oak Logs}} being removed from the bank.
The above code will result in 10 {{ItemIcon|Oak Logs}} being removed from the bank.


== Add GP ==
== Adjust Currencies (GP, Slayer Coins, and Raid Coins) ==
The gp.add function can be used to add [[Currency#Gold Pieces|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:
  <syntaxhighlight lang="js">game.gp.add(amount)</syntaxhighlight>
* To adjust GP, use <syntaxhighlight lang="js" inline>game.gp</syntaxhighlight>
=== Attributes ===
* To adjust SC, use <syntaxhighlight lang="js" inline>game.sc</syntaxhighlight>
* To adjust RC, use <syntaxhighlight lang="js" inline>game.rc</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
|}
|}
=== Examples ===
 
==== Examples ====
  <nowiki>game.gp.add(1);</nowiki>
  <nowiki>game.gp.add(1);</nowiki>
The above code will add 1 [[Currency#Gold Pieces|GP]] to the player.
The above code will add 1 [[Currency#Gold Pieces|GP]] to the player.


== Remove GP ==
=== Remove Currency ===
The gp.remove 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 GP will go into the negatives.
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.gp.remove(amount)</syntaxhighlight>
  <syntaxhighlight lang="js">game.<currency>.remove(amount)</syntaxhighlight>
=== Attributes ===
 
==== 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 ===
<syntaxhighlight lang="js">game.gp.remove(1);</syntaxhighlight>
The above code will remove 1 [[Currency#Gold Pieces|GP]] from the player.


== Add Slayer Coins ==
==== Examples ====
The slayerCoins.add function can be used to add [[Currency#Slayer Coins|Slayer Coins]] to a player.
  <syntaxhighlight lang="js">game.rc.remove(1);</syntaxhighlight>
<syntaxhighlight lang="js">game.slayerCoins.add(amount)</syntaxhighlight>
The above code will remove 1 [[Raid Coins|Raid Coin]] from the player.
=== Attributes ===
{| class="wikitable"
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
| amount || int || No || || The quantity of slayer coins to add.
|}
=== Examples ===
  <syntaxhighlight lang="js">game.slayerCoins.add(1);</syntaxhighlight>
The above code will add 1 [[Currency#Slayer Coins|Slayer Coin]] to the player.


== Remove Slayer Coins ==
=== Set Currency ===
The slayerCoins.remove function can be used to remove [[Currency#Slayer Coins|Slayer Coins]] from a player. If the amount specified is greater than the amount the player currently has, then slayer coins will go into the negatives.
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.slayerCoins.remove(amount)</syntaxhighlight>
  <syntaxhighlight lang="js">game.<currency>.set(amount)</syntaxhighlight>
=== Attributes ===
{| class="wikitable"
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
| amount || int || No || || The quantity of slayer coins to remove
|}
=== Examples ===
  <syntaxhighlight lang="js">game.slayerCoins.remove(1);</syntaxhighlight>
The above code will remove 1 [[Currency#Slayer Coins|Slayer Coin]] from the player.


== Add Raid Coins==
==== Attributes ====
The raidCoins.add function can be used to add [[Currency#Raid Coins|Raid Coins]] to a player.
<syntaxhighlight lang="js">game.raidCoins.add(amount)</syntaxhighlight>
=== Attributes ===
{| class="wikitable"
{| class="wikitable"
|-
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
|-
| amount || int || Yes || 0 || The quantity of raid coins to be added.
| amount || int || No || || The amount to set the specified currency's balance to
|}
|}
=== Examples ===
<syntaxhighlight lang="js">game.raidCoins.add(1);</syntaxhighlight>
The above will add 1 [[Currency#Raid Coins|Raid Coin]] to the player.


== Remove Raid Coins==
==== Examples ====
The raidCoins.remove function can be used to remove [[Currency#Raid Coins|Raid Coins]] from a player.
  <syntaxhighlight lang="js">game.sc.set(999);</syntaxhighlight>
<syntaxhighlight lang="js">game.raidCoins.remove(amount)</syntaxhighlight>
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.
=== Attributes ===
{| class="wikitable"
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
| amount || int || Yes || 0 || The quantity of raid coins to be removed.
|}
=== Examples ===
  <syntaxhighlight lang="js">game.raidCoins.remvoe(1);</syntaxhighlight>
The above will remove 1 [[Currency#Raid Coins|Raid Coin]] from the player.


== Add Prayer Points ==
== Add Prayer Points ==

Revision as of 23:46, 20 July 2023

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 it will show in item completion log
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)

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.sc
  • To adjust RC, use game.rc

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.rc.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.sc.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.