Anonymous

In-game Functions: Difference between revisions

From Melvor Idle
no edit summary
(Added a note with a link to instructions on using these with Steam)
No edit summary
Line 1: Line 1:
{{V|0.19.1}}
{{V|1.0}}
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 33: Line 33:
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 10 items with item ID 1 (Oak Logs) being added to the Bank without them appearing in the item completion log, but with notification.


== addXP ==
== removeItemFromBank ==
The 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 removeItemFromBank function can be used to remove any item from the bank
  <nowiki>addXP(skillID, xp, forceSkill, dropRares)</nowiki>
<nowiki>removeItemFromBank(itemID, deactiveGloves)</nowiki>
 
=== Attributes ===
{| class="wikitable"
|-
! 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]]
|-
| 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.
|}
 
=== Examples ===
<nowiki>removeItemFromBank(1);</nowiki>
The above code will result in item ID 1 (Oak Logs) being removed from the bank.
 
== player.addGP ==
The player.addGP function can be used to add gp to a player.
<nowiki>player.addGP(amount, source)</nowiki>
=== Attributes ===
{| class="wikitable"
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
| amount|| int || No || || The quantity of GP to add
|-
| 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 ==
The player.removeGP function can be used to remove gp from a player.
<nowiki>player.addGP(amount)</nowiki>
=== Attributes ===
{| class="wikitable"
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
| amount|| int || No || || The quantity of GP to remove
|}
=== Examples ===
<nowiki>player.removeGP(1);</nowiki>
The above code will remove 1 gp from the player.
 
== player.addPrayerPoints ==
The player.addPrayerPoints function can be used to add prayer points to a player.
<nowiki>player.addPrayerPoints(amount)</nowiki>
=== Attributes ===
{| class="wikitable"
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
| amount|| int || No || || The quantity of prayer points to add.
|}
=== Examples ===
<nowiki>player.addPrayerPoints(1);</nowiki>
The above code will add 1 prayer point to the player, and update player stats.
 
== player.addSlayerCoins ==
The player.addSlayerCoins function can be used to add slayer coins to a player.
<nowiki>player.addSlayerCoins(amount)</nowiki>
=== Attributes ===
{| class="wikitable"
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
| amount|| int || No || || The quantity of slayer coins to add.
|}
=== Examples ===
<nowiki>player.addSlayerCoins(1);</nowiki>
The above code will add 1 slayer coin to the player, and update player stats.
 
== player.addXP ==
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.
  <nowiki>player.addXP(skillID, xp, forceSkill, dropRares)</nowiki>
=== Attributes ===
=== Attributes ===
{| class="wikitable"
{| class="wikitable"
Line 50: Line 128:
|}
|}
=== Examples ===
=== Examples ===
  <nowiki>addXP(10, 1000);</nowiki>
  <nowiki>player.addXP(10, 1000);</nowiki>
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 the skill with ID 10 (Thieving).


== addMasteryXP ==
== player.addMasteryXP ==
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 player.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.  
  <nowiki>addMasteryXP(skillID, masteryID, timePerAction, spendingXP, xp, addToPool, offline)</nowiki>
  <nowiki>player.addMasteryXP(skillID, masteryID, timePerAction, spendingXP, xp, addToPool, offline)</nowiki>
=== Attributes ===
=== Attributes ===
{| class="wikitable"
{| class="wikitable"
Line 107: Line 185:


=== Examples ===
=== Examples ===
  <nowiki>addMasteryXP(11, 13, 0, true, 300);</nowiki>
  <nowiki>player.addMasteryXP(11, 13, 0, true, 300);</nowiki>
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 Mastery XP being added to the skill with ID 11 (Farming) for Mastery ID 13 (Carrot Seeds).


  <nowiki>addMasteryXP(2, 3, 3000);</nowiki>
  <nowiki>player.addMasteryXP(2, 3, 3000);</nowiki>
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 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.
== player.addMasteryXpToPool ==
The player.addMasteryXpToPool function can be used to add mastery pool experience to a skill
<nowiki>player.addMasteryXP(skillID, xp, offline, token)</nowiki>
=== Attributes ===
{| class="wikitable"
|-
! 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. 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 ===
<nowiki>player.addMasteryXpToPool(11, 600);</nowiki>
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
<nowiki>player.addMasteryXP(11, 600, false, true);</nowiki>
The above code will result in 600 Mastery Pool XP being added to the skill with ID 11 (Farming) regardless of the level of the player in the skill.


== Reference Tables ==
== Reference Tables ==
166

edits