In-game Functions: Difference between revisions

Added finding ancient relics
m (→‎Unlock Pet: Added a command to find all pet IDs)
(Added finding ancient relics)
Line 234: Line 234:
The above code discovers a single mark for the {{ItemIcon|Dragon}} familiar.
The above code discovers a single mark for the {{ItemIcon|Dragon}} familiar.


== Locate Ancient Relic ==
The <code>locateAncientRelic</code> function is used to locate [[Ancient Relics#List_of_Ancient_Relics|Ancient Relics]].
<syntaxhighlight lang="js">game.<skill>.locateAncientRelic(relicSet, relic)</syntaxhighlight>
where <code><skill></code> is the lowercase name of the skill you wish to add a relic to.
=== Attributes ===
{| class="wikitable"
|-
! Attribute !! Type !! Optional? !! Default Value !! Description
|-
| relicSet || object || No || || The relicSet that the relic belongs to. Obtained with <syntaxhighlight lang="js" inline>game.<skill>.ancientRelicSets.get(realm)</syntaxhighlight>
A list of realms IDs can be obtained by entering the following into the console: <syntaxhighlight lang="js" inline>console.log(game.realms.allObjects.map((a) => a.id + ' - ' + a.name).join('\n'))</syntaxhighlight>. To convert the realmID into a realm object, use <syntaxhighlight lang="js" inline>game.realms.getObjectByID('realmID')</syntaxhighlight>.
|-
| relic || object || No || || The relic that you wish to add.
The relic can be obtained with <syntaxhighlight lang="js" inline><relicSet>.relicDrops.find(x => x.relic.id.toLowerCase().includes('relic<#>'));</syntaxhighlight> where <code><#></code> is replaced with the relic number, starting from 1 and ending with 5.
|}
=== Examples ===
<syntaxhighlight lang="js">
let realm = game.realms.getObjectByID('melvorD:Melvor');
let relicSet = game.woodcutting.ancientRelicSets.get(realm);
let relicDrop = relicSet.relicDrops.find(x => x.relic.id.toLowerCase().includes('relic1'));
if (!relicSet.foundRelics.has(relicDrop.relic))
    game.woodcutting.locateAncientRelic(relicSet, relic);
</syntaxhighlight>
The above code locates Woodcutting Relic 1 in the Melvor Realm.
<syntaxhighlight lang="js">
game.skills.forEach(skill => {
let realm = game.realms.getObjectByID('melvorD:Melvor');
let relicSet = skill.ancientRelicSets.get(realm);
if (skill.hasAncientRelics)
relicSet.relicDrops.forEach(({ relic }) => {
if (!relicSet.foundRelics.has(relic))
skill.locateAncientRelic(relicSet, relic)
});
});
</syntaxhighlight>
The above will add all ancient relics to every skill, including modded skills.
{{Menu}}
{{Menu}}