In-game Functions: Difference between revisions
m (Bump version) |
(Use SyntaxHighlight) |
||
Line 11: | Line 11: | ||
== Add Item to Bank == | == Add Item to Bank == | ||
The addItemByID 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. | ||
< | <syntaxhighlight lang="js">game.bank.addItemByID(itemID, quantity, logLost, found, ignoreSpace)</syntaxhighlight> | ||
=== Attributes === | === Attributes === | ||
Line 30: | Line 30: | ||
=== Examples === | === Examples === | ||
< | <syntaxhighlight lang="js">game.bank.addItemByID("melvorD:Oak_Logs", 10, true, true, false);</syntaxhighlight> | ||
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. | 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. | ||
== Remove Item from Bank == | == Remove Item from Bank == | ||
The removeItemQuantityByID function can be used to remove any item from the bank | The removeItemQuantityByID function can be used to remove any item from the bank | ||
< | <syntaxhighlight lang="js">game.bank.removeItemQuantityByID(itemID, quantity, removeItemCharges)</syntaxhighlight> | ||
=== Attributes === | === Attributes === | ||
Line 50: | Line 50: | ||
=== Examples === | === Examples === | ||
< | <syntaxhighlight lang="js">game.bank.removeItemQuantityByID("melvorD:Oak_Logs", 10);</syntaxhighlight> | ||
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 == | == Add GP == | ||
The gp.add function can be used to add [[Currency#Gold Pieces|GP]] to a player. | The gp.add function can be used to add [[Currency#Gold Pieces|GP]] to a player. | ||
< | <syntaxhighlight lang="js">game.gp.add(amount)</syntaxhighlight> | ||
=== Attributes === | === Attributes === | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 69: | Line 69: | ||
== Remove GP == | == Remove GP == | ||
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 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. | ||
< | <syntaxhighlight lang="js">game.gp.remove(amount)</syntaxhighlight> | ||
=== Attributes === | === Attributes === | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 78: | Line 78: | ||
|} | |} | ||
=== Examples === | === Examples === | ||
< | <syntaxhighlight lang="js">game.gp.remove(1);</syntaxhighlight> | ||
The above code will remove 1 [[Currency#Gold Pieces|GP]] from the player. | The above code will remove 1 [[Currency#Gold Pieces|GP]] from the player. | ||
== Add Slayer Coins == | == Add Slayer Coins == | ||
The slayerCoins.add function can be used to add [[Currency#Slayer Coins|Slayer Coins]] to a player. | The slayerCoins.add function can be used to add [[Currency#Slayer Coins|Slayer Coins]] to a player. | ||
< | <syntaxhighlight lang="js">game.slayerCoins.add(amount)</syntaxhighlight> | ||
=== Attributes === | === Attributes === | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 92: | Line 92: | ||
|} | |} | ||
=== Examples === | === Examples === | ||
< | <syntaxhighlight lang="js">game.slayerCoins.add(1);</syntaxhighlight> | ||
The above code will add 1 [[Currency#Slayer Coins|Slayer Coin]] to the player. | The above code will add 1 [[Currency#Slayer Coins|Slayer Coin]] to the player. | ||
== Remove Slayer Coins == | == Remove Slayer Coins == | ||
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 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. | ||
< | <syntaxhighlight lang="js">game.slayerCoins.remove(amount)</syntaxhighlight> | ||
=== Attributes === | === Attributes === | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 106: | Line 106: | ||
|} | |} | ||
=== Examples === | === Examples === | ||
< | <syntaxhighlight lang="js">game.slayerCoins.remove(1);</syntaxhighlight> | ||
The above code will remove 1 [[Currency#Slayer Coins|Slayer Coin]] from the player. | The above code will remove 1 [[Currency#Slayer Coins|Slayer Coin]] from the player. | ||
== Add Raid Coins== | == Add Raid Coins== | ||
The raidCoins.add function can be used to add [[Currency#Raid Coins|Raid Coins]] to a player. | 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 === | === Attributes === | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 120: | Line 120: | ||
|} | |} | ||
=== Examples === | === Examples === | ||
< | <syntaxhighlight lang="js">game.raidCoins.add(1);</syntaxhighlight> | ||
The above will add 1 [[Currency#Raid Coins|Raid Coin]] to the player. | The above will add 1 [[Currency#Raid Coins|Raid Coin]] to the player. | ||
== Remove Raid Coins== | == Remove Raid Coins== | ||
The raidCoins.remove function can be used to remove [[Currency#Raid Coins|Raid Coins]] from a player. | The raidCoins.remove function can be used to remove [[Currency#Raid Coins|Raid Coins]] from a player. | ||
< | <syntaxhighlight lang="js">game.raidCoins.remove(amount)</syntaxhighlight> | ||
=== Attributes === | === Attributes === | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 134: | Line 134: | ||
|} | |} | ||
=== Examples === | === Examples === | ||
< | <syntaxhighlight lang="js">game.raidCoins.remvoe(1);</syntaxhighlight> | ||
The above will remove 1 [[Currency#Raid Coins|Raid Coin]] from the player. | The above will remove 1 [[Currency#Raid Coins|Raid Coin]] from the player. | ||
== Add Prayer Points == | == Add Prayer Points == | ||
The combat.player.addPrayerPoints function can be used to add prayer points to a player. | 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 148: | Line 148: | ||
|} | |} | ||
=== Examples === | === Examples === | ||
< | <syntaxhighlight lang="js">game.combat.player.addPrayerPoints(1);</syntaxhighlight> | ||
The above code will add 1 prayer point to the player, and update player stats. | The above code will add 1 prayer point to the player, and update player stats. | ||
== Add XP == | == Add XP == | ||
The addXP function can be used to add experience to any skill. | The addXP function can be used to add experience to any skill. | ||
< | <syntaxhighlight lang="js">game.skill.addXP(xp)</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. | ||
=== Attributes === | === Attributes === | ||
Line 163: | Line 163: | ||
|} | |} | ||
=== Examples === | === Examples === | ||
< | <syntaxhighlight lang="js">game.thieving.addXP(1000);</syntaxhighlight> | ||
The above code will result in 1000 experience being added to {{Skill|Thieving}}. | The above code will result in 1000 experience being added to {{Skill|Thieving}}. | ||
== Add Mastery XP == | == Add Mastery XP == | ||
The addMasteryXP function can be used to add experience to any specific {{Icon|Mastery}} in a skill. | The addMasteryXP function can be used to add experience to any specific {{Icon|Mastery}} in a skill. | ||
< | <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. | where <code>skill</code> is the lowercase name of the skill you are adding mastery experience to. | ||
=== Attributes === | === Attributes === | ||
Line 175: | Line 175: | ||
! Attribute !! Type !! Optional? !! Default Value !! Description | ! Attribute !! Type !! Optional? !! Default Value !! Description | ||
|- | |- | ||
| masteryAction || object || No || || The action to add Mastery XP to. Obtained with < | | 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: < | 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>. | ||
|- | |- | ||
| xp || int || Yes || 0 || Amount of experience to add. | | xp || int || Yes || 0 || Amount of experience to add. | ||
Line 183: | Line 183: | ||
=== Examples === | === Examples === | ||
< | <syntaxhighlight lang="js">game.farming.addMasteryXP(game.farming.actions.getObjectByID('melvorD:Carrot'), 300);</syntaxhighlight> | ||
The above code will result in 300 {{Icon|Mastery}} XP being added to {{Skill|Farming}} for {{ItemIcon|Carrot Seeds}}. | The above code will result in 300 {{Icon|Mastery}} XP being added to {{Skill|Farming}} for {{ItemIcon|Carrot Seeds}}. | ||
< | <syntaxhighlight lang="js">game.firemaking.addMasteryXP(game.firemaking.actions.getObjectByID('melvorD:Teak_Logs'), 3000);</syntaxhighlight> | ||
The above code will result in 3,000 {{Icon|Mastery}} XP being added to {{Skill|Firemaking}} for {{ItemIcon|Teak Logs}}. | The above code will result in 3,000 {{Icon|Mastery}} XP being added to {{Skill|Firemaking}} for {{ItemIcon|Teak Logs}}. | ||
== Add Mastery XP to Pool== | == Add Mastery XP to Pool== | ||
The addMasteryPoolXP function can be used to add [[Mastery#The_Mastery_Pool|Mastery Pool]] experience to a skill | The addMasteryPoolXP function can be used to add [[Mastery#The_Mastery_Pool|Mastery Pool]] experience to a skill | ||
< | <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. | where <code>skill</code> is the lowercase name of the skill you are adding mastery experience to. | ||
=== Attributes === | === Attributes === | ||
Line 201: | Line 201: | ||
|} | |} | ||
=== Examples === | === Examples === | ||
< | <syntaxhighlight lang="js">game.woodcutting.addMasteryPoolXP(600);</syntaxhighlight> | ||
The above code will result in 600 [[Mastery#The_Mastery_Pool|Mastery Pool]] XP being added to {{Skill|Woodcutting}}. | The above code will result in 600 [[Mastery#The_Mastery_Pool|Mastery Pool]] XP being added to {{Skill|Woodcutting}}. | ||
== Unlock Pet == | == 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. | 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. | ||
< | <syntaxhighlight lang="js">game.petManager.unlockPetByID(petID)</syntaxhighlight> | ||
=== Attributes === | === Attributes === | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 215: | Line 215: | ||
|} | |} | ||
=== Examples === | === Examples === | ||
< | <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}}. | ||
== Discover Mark == | == Discover Mark == | ||
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. | 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. | ||
< | <syntaxhighlight lang="js">game.summoning.discoverMark(mark)</syntaxhighlight> | ||
=== Attributes === | === Attributes === | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 226: | Line 226: | ||
! Attribute !! Type !! Optional? !! Default Value !! Description | ! Attribute !! Type !! Optional? !! Default Value !! Description | ||
|- | |- | ||
| mark || object || No || || The mark to discover. Obtained with < | | 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. | ||
A list of mark IDs can be obtained by entering the following into the console: < | 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>. | ||
|} | |} | ||
=== Examples === | === 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. | The above code discovers a single mark for the {{ItemIcon|Dragon}} familiar. |
Revision as of 11:11, 2 January 2023
This page was last updated for (v1.1.1). |
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.
Using In-game Functions On Steam
Players can use the dev.Console mod to execute these commands within 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, 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.
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
.
Add Mastery XP
The addMasteryXP function can be used to add experience to any specific
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: | |
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
XP being added to
for Carrot Seeds.
game.firemaking.addMasteryXP(game.firemaking.actions.getObjectByID('melvorD:Teak_Logs'), 3000);
The above code will result in 3,000
XP being added to
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
.
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 Error creating thumbnail: File missing Ty for example).
|
Examples
game.petManager.unlockPetByID('melvorD:CoolRock');
The above code will result in the unlocking of
.
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: |
Examples
game.summoning.discoverMark(game.summoning.actions.getObjectByID('melvorF:Dragon'));
The above code discovers a single mark for the
familiar.