Anonymous

In-game Functions: Difference between revisions

From Melvor Idle
Updated all functions on the page; Bumped version to 1.3; All Relics function will now add relics for all realms instead of just Melvor
(Updated all functions on the page; Bumped version to 1.3; All Relics function will now add relics for all realms instead of just Melvor)
Line 1: Line 1:
{{V|1.1.2}}
{{UserContentVersion|1.3}}
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 12: Line 12:


== 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 <code>addItemByID</code> 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>
  <syntaxhighlight lang="js">game.bank.addItemByID(itemID, quantity, logLost, found, ignoreSpace, notify)</syntaxhighlight>


=== Attributes ===
=== Attributes ===
Line 34: Line 34:
|-
|-
| ignoreSpace || 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
|-
| notify || boolean || Yes || true || If <code>true</code>, there will be a notification that the item was added along with the quantity.
|}
|}


Line 39: Line 41:
  <syntaxhighlight lang="js">game.bank.addItemByID("melvorD:Oak_Logs", 10, true, true, false);</syntaxhighlight>
  <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.
<syntaxhighlight lang="js">game.items.forEach((item) => game.bank.addItem(item, 1000000, false, true, true, false));</syntaxhighlight>
The above code will add 1,000,000 of every item in the game. The items will be forced into the bank even if you do not have room and there will be no notifications upon adding the items.


== Remove Item from Bank ==
== Remove Item from Bank ==
The removeItemQuantityByID function can be used to remove any item from the bank
The <code>removeItemQuantityByID</code> function can be used to remove any item from the bank
  <syntaxhighlight lang="js">game.bank.removeItemQuantityByID(itemID, quantity, removeItemCharges)</syntaxhighlight>
  <syntaxhighlight lang="js">game.bank.removeItemQuantityByID(itemID, quantity, removeItemCharges)</syntaxhighlight>


Line 82: Line 86:
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.


== Adjust Currencies (GP, Slayer Coins, and Raid Coins) ==
== Adjust Currencies (GP, AP, Slayer Coins, Abyssal 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:
All [[Currency|Currencies]] within the game, being {{GP}} [[GP]], {{AP}} [[Abyssal Pieces]] (AP), {{SC}} [[Slayer Coins]] (SC), {{ASC}} [[Abyssal Slayer Coins]] (ASC), and {{RC}} [[Raid Coins]] (RC) can be adjusted using the same set of functions:
* To adjust GP, use <syntaxhighlight lang="js" inline>game.gp</syntaxhighlight>
* To adjust GP, use <syntaxhighlight lang="js" inline>game.gp</syntaxhighlight>
* To adjust GP, use <syntaxhighlight lang="js" inline>game.abyssalPieces</syntaxhighlight>
* To adjust SC, use <syntaxhighlight lang="js" inline>game.slayerCoins</syntaxhighlight>
* To adjust SC, use <syntaxhighlight lang="js" inline>game.slayerCoins</syntaxhighlight>
* To adjust SC, use <syntaxhighlight lang="js" inline>game.abyssalSlayerCoins</syntaxhighlight>
* To adjust RC, use <syntaxhighlight lang="js" inline>game.raidCoins</syntaxhighlight>
* To adjust RC, use <syntaxhighlight lang="js" inline>game.raidCoins</syntaxhighlight>


=== Add Currency ===
=== Add Currency ===
The game.''currency''.add function can be used to add to the player's current balance of that 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>
  <syntaxhighlight lang="js">game.<currency>.add(amount)</syntaxhighlight>


Line 105: Line 111:


=== Remove Currency ===
=== 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.
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>
  <syntaxhighlight lang="js">game.<currency>.remove(amount)</syntaxhighlight>


Line 117: Line 123:


==== Examples ====
==== Examples ====
  <syntaxhighlight lang="js">game.raidCoins.remove(1);</syntaxhighlight>
  <syntaxhighlight lang="js">game.abyssalSlayerCoins.remove(2);</syntaxhighlight>
The above code will remove 1 [[Raid Coins|Raid Coin]] from the player.
The above code will remove 2 [[Abyssal Slayer Coins]] from the player.


=== Set Currency ===
=== 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>.
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>
  <syntaxhighlight lang="js">game.<currency>.set(amount)</syntaxhighlight>


Line 133: Line 139:


==== Examples ====
==== Examples ====
  <syntaxhighlight lang="js">game.slayerCoins.set(999);</syntaxhighlight>
  <syntaxhighlight lang="js">game.raidCoins.set(999);</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.
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 ==
== Add or Remove Prayer Points or Soul Points ==
The combat.player.addPrayerPoints function can be used to add prayer points to a player.
The <code>addPrayerPoints</code> and <code>addSoulPoints</code> functions can be used to add prayer points or soul points to a player.
  <syntaxhighlight lang="js">game.combat.player.addPrayerPoints(amount)</syntaxhighlight>
  <syntaxhighlight lang="js">
game.combat.player.addPrayerPoints(amount);
game.combat.player.addSoulPoints(amount);
</syntaxhighlight>
=== Attributes ===
=== Attributes ===
{| class="wikitable"
{| class="wikitable"
Line 144: Line 153:
! 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 quantity of prayer or soul points to add. A negative value will remove points.
|}
|}
=== Examples ===
=== Examples ===
  <syntaxhighlight lang="js">game.combat.player.addPrayerPoints(1);</syntaxhighlight>
  <syntaxhighlight lang="js">
The above code will add 1 prayer point to the player, and update player stats.
game.combat.player.addPrayerPoints(1);
game.combat.player.addSoulPoints(-50);
</syntaxhighlight>
The first line will add 1 prayer point to the player while the second will remove 50 soul points.


== Add XP ==
== Add or Remove XP or Abyssal XP ==
The addXP and addAbyssalXP functions can be used to add experience and abyssal experience to any skill.
The <code>addXP</code> and <code>addAbyssalXP</code> functions can be used to add experience and abyssal experience to any skill.
  <syntaxhighlight lang="js">
  <syntaxhighlight lang="js">
game.<skill>.addXP(xp);
game.<skill>.addXP(xp);
Line 162: Line 174:
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
|-
| xp || int || No || || Amount of experience to add.
| xp || int || No || || Amount of experience to add. A negative value will remove experience.
|}
|}
=== Examples ===
=== Examples ===
  <syntaxhighlight lang="js">
  <syntaxhighlight lang="js">
game.thieving.addXP(1000);
game.thieving.addXP(1000);
game.thieving.addAbyssalXP(1000);
game.thieving.addAbyssalXP(-700);
</syntaxhighlight>
</syntaxhighlight>
The above lines will result in 1000 experience and abyssal experience being added to {{Skill|Thieving}}.
The first line will result in 1000 experience being added to {{Skill|Thieving}} while the second line will remove 700 abyssal xp from Thieving.


== Add Mastery XP ==
== Add or Remove Mastery XP ==
The addMasteryXP function can be used to add experience to any specific {{Icon|Mastery}} in a skill.
The <code>addMasteryXP</code> function can be used to add experience to any specific {{Icon|Mastery}} in a skill.
  <syntaxhighlight lang="js">game.skill.addMasteryXP(masteryAction, xp)</syntaxhighlight>
  <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 ===
{| class="wikitable"
{| class="wikitable"
Line 184: Line 196:
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>.
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. A negative value will remove mastery xp.
|}
|}


=== Examples ===
=== Examples ===
  <syntaxhighlight lang="js">game.farming.addMasteryXP(game.farming.actions.getObjectByID('melvorD:Carrot'), 300);</syntaxhighlight>
  <syntaxhighlight lang="js">
The above code will result in 300 {{Icon|Mastery}} XP being added to {{Skill|Farming}} for {{ItemIcon|Carrot Seeds}}.
game.farming.addMasteryXP(game.farming.actions.getObjectByID('melvorD:Carrot'), 300);
game.farming.addMasteryXP(game.farming.actions.getObjectByID('melvorD:Carrot'), -500);
</syntaxhighlight>
The first line will result in 300 {{Icon|Mastery}} XP being added to {{Skill|Farming}} for {{ItemIcon|Carrot Seeds}} whereas the second line will remove 500 Mastery XP from Carrot Seeds.


  <syntaxhighlight lang="js">game.firemaking.addMasteryXP(game.firemaking.actions.getObjectByID('melvorD:Teak_Logs'), 3000);</syntaxhighlight>
  <syntaxhighlight lang="js">game.masterySkills.forEach(skill => skill.actions.forEach(action => skill.addMasteryXP(action, 5000)));</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 5,000 {{Icon|Mastery}} XP being added to every action within every skill with a mastery action.


== Add Mastery XP to Pool==
== Add or Remove Mastery XP to Pool==
The addMasteryPoolXP function can be used to add [[Mastery#The_Mastery_Pool|Mastery Pool]] experience to a skill
The <code>addMasteryPoolXP</code> function can be used to add [[Mastery#The_Mastery_Pool|Mastery Pool]] experience to a skill
  <syntaxhighlight lang="js">game.<skill>.addMasteryPoolXP(realm, xp)</syntaxhighlight>
  <syntaxhighlight lang="js">game.<skill>.addMasteryPoolXP(realm, 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.
Line 203: Line 218:
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
|-
| realm || object || No || || The realm to add the Mastery Pool XP to. Obtained with <code>game.realms.getObjectByID(id)</code> where the id is the ID of the realm.
| realm || object || No || || The realm to add the Mastery Pool XP to. Obtained with <code>game.realms.getObjectByID(realmID)</code>.


A list of action IDs can be obtained by entering the following into the console: <code>console.log(game.realms.allObjects.map((a) => a.id + ' - ' + a.name).join('\n'))</code>.
A list of realm IDs can be obtained by entering the following into the console: <code>console.log(game.realms.allObjects.map((a) => a.id + ' - ' + a.name).join('\n'))</code>.
|-
|-
| xp || int || Yes || 0 || Amount of experience to add.
| xp || int || Yes || 0 || Amount of experience to add. A negative value will remove mastery pool xp.
|}
|}
=== Examples ===
=== Examples ===
  <syntaxhighlight lang="js">game.woodcutting.addMasteryPoolXP(game.realms.getObjectByID('melvorD:Melvor'), 600);</syntaxhighlight>
  <syntaxhighlight lang="js">
The above code will result in 600 [[Mastery#The_Mastery_Pool|Mastery Pool]] XP being added to {{Skill|Woodcutting}} in the Melvor Realm.
game.woodcutting.addMasteryPoolXP(game.realms.getObjectByID('melvorD:Melvor'), 600);
game.woodcutting.addMasteryPoolXP(game.realms.getObjectByID('melvorD:Melvor'), -400);
</syntaxhighlight>
The first line will result in 600 [[Mastery#The_Mastery_Pool|Mastery Pool]] XP being added to {{Skill|Woodcutting}} in the Melvor Realm whereas the second line will remove 400 mastery pool xp from Woodcutting.
 
<syntaxhighlight lang="js">game.realms.forEach(realm => game.masterySkills.forEach(skill => skill.addMasteryPoolXP(realm, 1000)));</syntaxhighlight>
The above code will result in 1,000 [[Mastery#The_Mastery_Pool|Mastery Pool]] XP being added to all skills in every realm.


== 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 <code>unlockPetByID</code> function is used to unlock [[Pets]].
  <syntaxhighlight lang="js">game.petManager.unlockPetByID(petID)</syntaxhighlight>
  <syntaxhighlight lang="js">game.petManager.unlockPetByID(petID)</syntaxhighlight>
=== Attributes ===
=== Attributes ===
Line 224: Line 245:
|}
|}
=== Examples ===
=== Examples ===
  <syntaxhighlight lang="js">game.petManager.unlockPetByID('melvorD:CoolRock');</syntaxhighlight>
  <syntaxhighlight lang="js">
The above code will result in the unlocking of {{PetIcon|Cool Rock}}.
game.petManager.unlockPetByID('melvorD:CoolRock');
game.petManager.unlocked.delete(game.pets.getObjectByID('melvorD:CoolRock'));game.petManager.computeProvidedStats();
</syntaxhighlight>
The fire line will result in the unlocking of {{PetIcon|Cool Rock}} while the second line will remove the Cool Rock then reload the player's stats.
<syntaxhighlight lang="js">game.pets.forEach(pet => game.petManager.unlockPet(pet));</syntaxhighlight>
The above code will unlock every single pet.


== 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 <code>discoverMark</code> function is used to discover [[Summoning#Summoning Marks|Summoning Marks]].
  <syntaxhighlight lang="js">game.summoning.discoverMark(mark)</syntaxhighlight>
  <syntaxhighlight lang="js">game.summoning.discoverMark(mark)</syntaxhighlight>
=== Attributes ===
=== Attributes ===
Line 241: Line 267:


=== Examples ===
=== Examples ===
  <syntaxhighlight lang="js">game.summoning.discoverMark(game.summoning.actions.getObjectByID('melvorF:Dragon'));</syntaxhighlight>
  <syntaxhighlight lang="js">
The above code discovers a single mark for the {{ItemIcon|Dragon}} familiar.
game.summoning.discoverMark(game.summoning.actions.getObjectByID('melvorF:Dragon'));
game.summoning.marksUnlocked.delete(game.summoning.actions.getObjectByID('melvorF:Dragon'));
</syntaxhighlight>
The first line discovers a single mark for the {{ItemIcon|Dragon}} familiar whereas the second line removes all marks from the Dragon.
<syntaxhighlight lang="js">
game.summoning.actions.forEach((mark) => {
game.summoning.marksUnlocked.set(mark, (mark.realm.id === 'melvorD:Melvor') ? 61 : 31);
game.summoning.renderQueue.markCount.add(mark);
game.summoning.renderQueue.markState.add(mark);
});
</syntaxhighlight>
The above code will set every single mark to level 61 if it's in the Melvor Realm and 31 if it's in the Abyssal Realm then update the mark count and mark states.


== Locate Ancient Relic ==
== Locate Ancient Relic ==
Line 274: Line 311:
  <syntaxhighlight lang="js">
  <syntaxhighlight lang="js">
game.skills.forEach(skill => {
game.skills.forEach(skill => {
let realm = game.realms.getObjectByID('melvorD:Melvor');
game.realms.forEach(realm => {
let relicSet = skill.ancientRelicSets.get(realm);
let relicSet = skill.ancientRelicSets.get(realm);
if (skill.hasAncientRelics)
if (skill.hasAncientRelics && relicSet !== undefined)
relicSet.relicDrops.forEach(({ relic }) => {
relicSet.relicDrops.forEach(({ relic }) => {
if (!relicSet.foundRelics.has(relic))
if (!relicSet.foundRelics.has(relic))
skill.locateAncientRelic(relicSet, relic)
skill.locateAncientRelic(relicSet, relic)
});
});
});
});
});
</syntaxhighlight>
</syntaxhighlight>
The above will add all ancient relics to every skill, including modded skills.
The above will add all ancient relics to every skill, including modded skills, from all realms.


== Reset all Equipment Quick Equip Items ==
== Reset all Equipment Quick Equip Items ==
Line 326: Line 364:
  <syntaxhighlight lang="js">
  <syntaxhighlight lang="js">
  game.combat.player.manager.addDungeonCompletion(game.dungeons.getObjectByID('melvorF:Into_the_Mist'));
  game.combat.player.manager.addDungeonCompletion(game.dungeons.getObjectByID('melvorF:Into_the_Mist'));
  game.combat.player.manager.setDungeonCompleteCount(game.dungeons.getObjectByID('melvorF:Into_the_Mist'), 69420);
  game.combat.player.manager.setDungeonCompleteCount(game.dungeons.getObjectByID('melvorF:Into_the_Mist'), 15);
</syntaxhighlight>
</syntaxhighlight>
The first line will add a single completion to {{ZoneIcon|Into the Mist}} while the second line will set the dungeon completions to 69420. Setting a dungeon completion count of 0 or lower will delete all completions from the dungeon.
The first line will add a single completion to {{ZoneIcon|Into the Mist}} while the second line will set the dungeon completions to 15.


After modifying the dungeon completion count, run <code>game.queueRequirementRenders();</code> to apply UI updates without having to restart the game.
After modifying the dungeon completion count, run <code>game.queueRequirementRenders();</code> to apply UI updates without having to restart the game.
{{Menu}}
{{Menu}}