Anonymous

In-game Functions: Difference between revisions

From Melvor Idle
Rewrite a couple sections to use namespaced IDs rather than array indexes
(Update Steam advice)
(Rewrite a couple sections to use namespaced IDs rather than array indexes)
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 <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.
| masteryAction || object || No || || The action to add Mastery XP to. Obtained with <code>game.skill.actions.getObjectByID(id)</code> 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: <code>console.log(game.skill.actions.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.
Line 181: Line 183:


=== Examples ===
=== Examples ===
  <nowiki>game.farming.addMasteryXP(game.farming.actions.allObjects[13], 300);</nowiki>
  <nowiki>game.farming.addMasteryXP(game.farming.actions.getObjectByID('melvorD:Carrot'), 300);</nowiki>
The above code will result in 300 {{Icon|Mastery}} XP being added to {{Skill|Farming}} for Mastery ID 13 (Carrot Seeds).
The above code will result in 300 {{Icon|Mastery}} XP being added to {{Skill|Farming}} for {{ItemIcon|Carrot Seeds}}.


  <nowiki>game.firemaking.addMasteryXP(game.firemaking.actions.allObjects[3], 3000);</nowiki>
  <nowiki>game.firemaking.addMasteryXP(game.firemaking.actions.getObjectByID('melvorD:Teak_Logs'), 3000);</nowiki>
The above code will result in 3000 {{Icon|Mastery}} XP being added to {{Skill|Firemaking}} for Mastery ID 3 (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==
Line 224: Line 226:
! Attribute !! Type !! Optional? !! Default Value !! Description
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
|-
| 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.
| mark || object || No || || The mark to discover. Obtained with <code>game.summoning.actions.getObjectByID(markID)</code> 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: <code>console.log(game.summoning.actions.allObjects.map((a) => a.id + ' - ' + a.name).join('\n'))</code>.
|}
|}
=== Examples ===
=== Examples ===
  <nowiki>game.summoning.discoverMark(game.summoning.actions.allObjects[15]);</nowiki>
  <nowiki>game.summoning.discoverMark(game.summoning.actions.getObjectByID('melvorF:Dragon'));</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.