In-game Functions: Difference between revisions
(Update for v1.0.5 & document discoverMark) |
(Updated the functions to the new game object format.) |
||
Line 1: | Line 1: | ||
{{V|1. | {{V|1.1}} | ||
{| class="warningbox" | |||
| '''Various sections of this page are incomplete or reference pages which have not been updated. Due to this, certain functions may not have all the information easily available on the wiki at this time.''' | |||
|} | |||
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. | ||
Line 11: | Line 14: | ||
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 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. | ||
== | == Add Item to Bank == | ||
The | The addItemByID function can be used to add any item in the game to the bank. | ||
<nowiki> | <nowiki>game.bank.addItemByID(itemID, quantity, found, showNotification, ignoreBankSpace)</nowiki> | ||
=== Attributes === | === Attributes === | ||
Line 20: | Line 23: | ||
! Attribute !! Type !! Optional? !! Default Value !! Description | ! Attribute !! Type !! Optional? !! Default Value !! Description | ||
|- | |- | ||
| itemID || | | 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. Will remove items from the bank if a negative value is specified | ||
Line 32: | Line 35: | ||
=== Examples === | === Examples === | ||
<nowiki> | <nowiki>game.bank.addItemByID("melvorD:Oak_Logs", 10, false);</nowiki> | ||
The above code will result in 10 items with item ID | The above code will result in 10 items with item ID melvorD:Oak_Logs being added to the Bank without them appearing in the item completion log, but with notification. | ||
== | == Remove Item from Bank == | ||
The | The removeItemQuantity function can be used to remove any item from the bank | ||
<nowiki> | <nowiki>game.bank.removeItemQuantity(itemID, quantity, removeItemCharges)</nowiki> | ||
=== Attributes === | === Attributes === | ||
Line 44: | Line 47: | ||
! Attribute !! Type !! Optional? !! Default Value !! Description | ! Attribute !! Type !! Optional? !! Default Value !! Description | ||
|- | |- | ||
| itemID || | | 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 || || 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> | <nowiki>game.bank.removeItemQuantity("melvorD:Oak_Logs", 10);</nowiki> | ||
The above code will result in item ID | The above code will result in 10 of item ID "melvorD:Oak_Logs" being removed from the bank. | ||
== | == Add GP == | ||
The | The gp.add function can be used to add [[Currency#Gold Pieces|GP]] to a player. | ||
<nowiki> | <nowiki>game.gp.add(amount)</nowiki> | ||
=== Attributes === | === Attributes === | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 62: | Line 67: | ||
|- | |- | ||
| amount|| int || No || || The quantity of GP to add | | amount|| int || No || || The quantity of GP to add | ||
|} | |} | ||
=== Examples === | === Examples === | ||
<nowiki> | <nowiki>game.gp.add(1);</nowiki> | ||
The above code will add 1 gp to the player. | |||
The above code will add 1 gp to the player | |||
== | == Remove GP == | ||
The | 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. | ||
<nowiki> | <nowiki>game.gp.remove(amount)</nowiki> | ||
=== Attributes === | === Attributes === | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 82: | Line 83: | ||
|} | |} | ||
=== Examples === | === Examples === | ||
<nowiki> | <nowiki>game.gp.remove(1);</nowiki> | ||
The above code will remove 1 GP from the player. | The above code will remove 1 GP from the player. | ||
== | == Add Slayer Coins == | ||
The | The slayerCoins.add function can be used to add slayer coins to a player. | ||
<nowiki> | <nowiki>game.slayerCoins.add(amount)</nowiki> | ||
=== Attributes === | === Attributes === | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 93: | Line 94: | ||
! 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 slayer coins to add. | ||
|} | |} | ||
=== Examples === | === Examples === | ||
<nowiki> | <nowiki>game.slayerCoins.add(1);</nowiki> | ||
The above code will add 1 slayer coin to the player | The above code will add 1 slayer coin to the player. | ||
== | == Remove Slayer Coins == | ||
The | The slayerCoins.remove 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 slayer coins will go into the negatives. | ||
<nowiki> | <nowiki>game.slayerCoins.remove(amount)</nowiki> | ||
=== Attributes === | === Attributes === | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 108: | Line 109: | ||
|- | |- | ||
| amount || int || No || || The quantity of slayer coins to remove | | amount || int || No || || The quantity of slayer coins to remove | ||
|} | |} | ||
=== Examples === | === Examples === | ||
<nowiki> | <nowiki>game.slayerCoins.remove(1);</nowiki> | ||
The above code will remove 1 slayer coin from the player | The above code will remove 1 slayer coin from the player. | ||
== | == Add Raid Coins== | ||
The | The raidCoins.add function can be used to add [[Currency#Raid Coins|raid coins]] to a player. | ||
<nowiki> | <nowiki>game.raidCoins.add(amount)</nowiki> | ||
=== Attributes === | === Attributes === | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 123: | Line 122: | ||
! 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 || Yes || 0 || The quantity of raid coins to be added. | ||
|} | |} | ||
=== Examples === | === Examples === | ||
<nowiki> | <nowiki>game.raidCoins.add(1);</nowiki> | ||
The above will add 1 raid coin to the player. | The above will add 1 raid coin to the player. | ||
== | == Remove Raid Coins== | ||
The | The raidCoins.remove function can be used to remove [[Currency#Raid Coins|raid coins]] from a player. | ||
<nowiki> | <nowiki>game.raidCoins.remove(amount)</nowiki> | ||
=== Attributes === | === Attributes === | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 137: | Line 136: | ||
! Attribute !! Type !! Optional? !! Default Value !! Description | ! Attribute !! Type !! Optional? !! Default Value !! Description | ||
|- | |- | ||
| amount || int || | | amount || int || Yes || 0 || The quantity of raid coins to be removed. | ||
|} | |} | ||
=== Examples === | === Examples === | ||
<nowiki> | <nowiki>game.raidCoins.remvoe(1);</nowiki> | ||
The above | The above will remove 1 raid coin from the player. | ||
== | == Add Prayer Points == | ||
The player. | The combat.player.addPrayerPoints function can be used to add prayer points to a player. | ||
<nowiki>player. | <nowiki>game.combat.player.addPrayerPoints(amount)</nowiki> | ||
=== Attributes === | === Attributes === | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 151: | Line 150: | ||
! Attribute !! Type !! Optional? !! Default Value !! Description | ! Attribute !! Type !! Optional? !! Default Value !! Description | ||
|- | |- | ||
| | | amount || int || No || || The quantity of prayer points to add. | ||
|} | |} | ||
=== Examples === | === Examples === | ||
<nowiki>player. | <nowiki>game.combat.player.addPrayerPoints(1);</nowiki> | ||
The above code will | The above code will add 1 prayer point to the player, and update player stats. | ||
== | == Add XP == | ||
The | The addXP function can be used to add experience to any skill. | ||
<nowiki> | <nowiki>game.skill.addXP(xp)</nowiki> | ||
where <code>skill</code> is the lowercase name of the skill you are adding experience to. | |||
=== Attributes === | === Attributes === | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 167: | Line 165: | ||
! Attribute !! Type !! Optional? !! Default Value !! Description | ! Attribute !! Type !! Optional? !! Default Value !! Description | ||
|- | |- | ||
| | | xp || int || No || || Amount of experience to add. | ||
|} | |} | ||
=== Mastery | === Examples === | ||
<nowiki>game.thieving.addXP(1000);</nowiki> | |||
The above code will result in 1000 experience being added to Theiving. | |||
== Add Mastery XP == | |||
The addMasteryXP function can be used to add experience to any specific Mastery in a skill. | |||
<nowiki>game.skill.addMasteryXP(masteryAction, xp)</nowiki> | |||
where <code>skill</code> is the lowercase name of the skill you are adding mastery experience to. | |||
=== Attributes === | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
! | ! Attribute !! Type !! Optional? !! Default Value !! Description | ||
|- | |- | ||
| | | masteryAction || object || No || || The action to add Mastery XP to. Obtained with <code>game.skill.actions.allObjects[n]</code> where n is the ID of the action, starting at 0. Also obtainable with <code>game.skill.actions.getObjectByID(id)</code> where id is the string ID of the action. | ||
|- | |- | ||
| | | xp || int || Yes || 0 || Amount of experience to add. | ||
|} | |} | ||
=== Examples === | === Examples === | ||
<nowiki>addMasteryXP( | <nowiki>game.farming.addMasteryXP(game.farming.actions.allObjects[13], 300);</nowiki> | ||
The above code will result in 300 Mastery XP being added to | The above code will result in 300 Mastery XP being added to Farming for Mastery ID 13 (Carrot Seeds). | ||
<nowiki>addMasteryXP( | <nowiki>game.firemaking.addMasteryXP(game.firemaking.actions.allObjects[3], 3000);</nowiki> | ||
The above code will result in | The above code will result in 3000 Mastery XP being added to Firemaking for Mastery ID 3 (Teak Logs). | ||
== | == Add Mastery XP to Pool== | ||
The | The addMasteryPoolXP function can be used to add mastery pool experience to a skill | ||
<nowiki> | <nowiki>game.skill.addMasteryPoolXP(xp)</nowiki> | ||
where <code>skill</code> is the lowercase name of the skill you are adding mastery experience to. | |||
=== Attributes === | === Attributes === | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 233: | Line 201: | ||
! Attribute !! Type !! Optional? !! Default Value !! Description | ! Attribute !! Type !! Optional? !! Default Value !! Description | ||
|- | |- | ||
| xp || int || Yes || 0 || Amount of experience to add. | |||
| xp || int || Yes || 0 || Amount of experience to add | |||
|} | |} | ||
=== Examples === | === Examples === | ||
<nowiki> | <nowiki>game.woodcutting.addMasterPoolXP(600);</nowiki> | ||
The above code will result in | The above code will result in 600 Mastery Pool XP being added to Woodcutting. | ||
== | == Unlock Pet == | ||
The | 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> | <nowiki>game.petManager.unlockPetByID(petID)</nowiki> | ||
=== Attributes === | === Attributes === | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 253: | Line 215: | ||
! Attribute !! Type !! Optional? !! Default Value !! Description | ! Attribute !! Type !! Optional? !! Default Value !! Description | ||
|- | |- | ||
| petID || | | petID || string || No || || The ID of the pet, which can be found on the individual pet pages (such as {{PetIcon|Ty}} for example). | ||
|} | |} | ||
=== Examples === | === Examples === | ||
<nowiki> | <nowiki>game.petManager.unlockPetByID("melvorD:CoolRock");</nowiki> | ||
The above code will result in the unlocking of {{PetIcon|Cool Rock}}. | The above code will result in the unlocking of {{PetIcon|Cool Rock}}. | ||
Line 269: | Line 229: | ||
! Attribute !! Type !! Optional? !! Default Value !! Description | ! Attribute !! Type !! Optional? !! Default Value !! Description | ||
|- | |- | ||
| mark || object || No || || | | mark || object || No || || The mark to discover. Obtained with <code>game.summoning.actions.allObjects[n]</code> where n is the ID of the mark, starting at 0. Also obtainable with <code>game.summoning.actions.getObjectByID(id)</code> where id is the string ID of the action. | ||
|} | |} | ||
=== Examples === | === Examples === | ||
<nowiki>game.summoning.discoverMark( | <nowiki>game.summoning.discoverMark(game.summoning.actions.allObjects[15]);</nowiki> | ||
The above code discovers a single mark for the {{ItemIcon|Dragon}} familiar. | The above code discovers a single mark for the {{ItemIcon|Dragon}} familiar. | ||
Revision as of 16:30, 18 October 2022
This page was last updated for (v1.1). |
Various sections of this page are incomplete or reference pages which have not been updated. Due to this, certain functions may not have all the information easily available on the wiki at this time. |
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 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
Players should refer to the Scripting and Extensions Instructions page for a step-by-step guide on using these functions with the Steam version 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, found, showNotification, ignoreBankSpace)
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. Will remove items from the bank if a negative value is specified | |
found | boolean | Yes | true | Determines if it will show in item completion log |
showNotification | boolean | Yes | true | Determines if it will show notification |
ignoreBankSpace | 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, false);
The above code will result in 10 items with item ID melvorD:Oak_Logs being added to the Bank without them appearing in the item completion log, but with notification.
Remove Item from Bank
The removeItemQuantity function can be used to remove any item from the bank
game.bank.removeItemQuantity(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.removeItemQuantity("melvorD:Oak_Logs", 10);
The above code will result in 10 of item ID "melvorD:Oak_Logs" being removed from the bank.
Add GP
The gp.add function can be used to add GP to a player.
game.gp.add(amount)
Attributes
Attribute | Type | Optional? | Default Value | Description |
---|---|---|---|---|
amount | int | No | The quantity of GP to add |
Examples
game.gp.add(1);
The above code will add 1 gp to the player.
Remove GP
The gp.remove function can be used to remove GP from a player. If the amount specified is greater than the amount the player currently has, then GP will go into the negatives.
game.gp.remove(amount)
Attributes
Attribute | Type | Optional? | Default Value | Description |
---|---|---|---|---|
amount | int | No | The quantity of GP to remove |
Examples
game.gp.remove(1);
The above code will remove 1 GP from the player.
Add Slayer Coins
The slayerCoins.add function can be used to add slayer coins to a player.
game.slayerCoins.add(amount)
Attributes
Attribute | Type | Optional? | Default Value | Description |
---|---|---|---|---|
amount | int | No | The quantity of slayer coins to add. |
Examples
game.slayerCoins.add(1);
The above code will add 1 slayer coin to the player.
Remove Slayer Coins
The slayerCoins.remove 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 slayer coins will go into the negatives.
game.slayerCoins.remove(amount)
Attributes
Attribute | Type | Optional? | Default Value | Description |
---|---|---|---|---|
amount | int | No | The quantity of slayer coins to remove |
Examples
game.slayerCoins.remove(1);
The above code will remove 1 slayer coin from the player.
Add Raid Coins
The raidCoins.add function can be used to add raid coins to a player.
game.raidCoins.add(amount)
Attributes
Attribute | Type | Optional? | Default Value | Description |
---|---|---|---|---|
amount | int | Yes | 0 | The quantity of raid coins to be added. |
Examples
game.raidCoins.add(1);
The above will add 1 raid coin to the player.
Remove Raid Coins
The raidCoins.remove function can be used to remove raid coins from a player.
game.raidCoins.remove(amount)
Attributes
Attribute | Type | Optional? | Default Value | Description |
---|---|---|---|---|
amount | int | Yes | 0 | The quantity of raid coins to be removed. |
Examples
game.raidCoins.remvoe(1);
The above will remove 1 raid coin from the player.
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 Theiving.
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.allObjects[n] where n is the ID of the action, starting at 0. Also obtainable with game.skill.actions.getObjectByID(id) where id is the string ID of the action.
| |
xp | int | Yes | 0 | Amount of experience to add. |
Examples
game.farming.addMasteryXP(game.farming.actions.allObjects[13], 300);
The above code will result in 300 Mastery XP being added to Farming for Mastery ID 13 (Carrot Seeds).
game.firemaking.addMasteryXP(game.firemaking.actions.allObjects[3], 3000);
The above code will result in 3000 Mastery XP being added to Firemaking for Mastery ID 3 (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.addMasterPoolXP(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 |
Examples
game.petManager.unlockPetByID("melvorD:CoolRock");
The above code will result in the unlocking of Cool Rock.
game.summoning.discoverMark
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.allObjects[n] where n is the ID of the mark, starting at 0. Also obtainable with game.summoning.actions.getObjectByID(id) where id is the string ID of the action.
|
Examples
game.summoning.discoverMark(game.summoning.actions.allObjects[15]);
The above code discovers a single mark for the Dragon familiar.