Anonymous

Template:Disambiguation/doc: Difference between revisions

From Melvor Idle
Add a script to search for objects that belong on disambiguation pages
(Created page with "Template that is used on Disambiguation pages. These are pages that are created to differentiate between multiple other pages with the same or a similar name. An example of this would be Siren")
 
(Add a script to search for objects that belong on disambiguation pages)
Line 2: Line 2:


An example of this would be [[Siren]]
An example of this would be [[Siren]]
The below script will search all current [[Template:Icon|Icon Templates]] in v1.2.2 (except for Synergies, Spellbooks and Currencies) for the given <code>searchTerm</code> then output an array of the results in valid Icon Template format. Requires a bit of cleanup before it can be used on the Wiki. You can right click + Copy Object on the output array to copy the array. With a good text editor such as Notepad++ or Sublime, you can select multiple lines which makes the cleanup take a few seconds.
<syntaxhighlight lang="javascript" line>
let searchTerm = ''.toLowerCase();
const search = (obj) => obj.name.toLowerCase().includes(searchTerm);
let results = [];
game.items.filter(x => search(x)).forEach(item => results.push({item: item, icon: 'ItemIcon'}));
game.monsters.filter(x => search(x)).forEach(monster => results.push({item: monster, icon: 'MonsterIcon'}));
game.skills.filter(x => search(x)).forEach(skill => results.push({item: skill, icon: 'Skill'}));
game.standardSpells.filter(x => search(x)).forEach(spell => results.push({item: spell, icon: 'SpellIcon'})); // In v1.3, these are
game.ancientSpells.filter(x => search(x)).forEach(spell => results.push({item: spell, icon: 'SpellIcon'})); // condensed into
game.archaicSpells.filter(x => search(x)).forEach(spell => results.push({item: spell, icon: 'SpellIcon'})); // game.attackSpells
game.curseSpells.filter(x => search(x)).forEach(spell => results.push({item: spell, icon: 'SpellIcon'}));
game.auroraSpells.filter(x => search(x)).forEach(spell => results.push({item: spell, icon: 'SpellIcon'}));
game.shop.purchases.filter(x => search(x)).forEach(purchase => results.push({item: purchase, icon: 'UpgradeIcon'}));
game.pets.filter(x => search(x)).forEach(pet => results.push({item: pet, icon: 'PetIcon'}));
game.prayers.filter(x => search(x)).forEach(prayer => results.push({item: prayer, icon: 'PrayerIcon'}));
game.combatAreas.filter(x => search(x)).forEach(area => results.push({item: area, icon: 'ZoneIcon'}));
game.slayerAreas.filter(x => search(x)).forEach(area => results.push({item: area, icon: 'ZoneIcon'}));
game.dungeons.filter(x => search(x)).forEach(area => results.push({item: area, icon: 'ZoneIcon'}));
game.astrology.actions.filter(x => search(x)).forEach(constellation => results.push({item: constellation, icon: 'ConstellationIcon'}));
game.township.buildings.filter(x => search(x)).forEach(building => results.push({item: building, icon: 'TownshipIcon'}));
game.township.seasons.filter(x => search(x)).forEach(season => results.push({item: season, icon: 'TownshipIcon'}));
game.township.biomes.filter(x => search(x)).forEach(biome => results.push({item: biome, icon: 'TownshipIcon'}));
game.township.resources.filter(x => search(x)).forEach(resource => results.push({item: resource, icon: 'TownshipIcon'}));
game.agility.actions.filter(x => search(x)).forEach(obstacle => results.push({item: obstacle, icon: 'AgilityIcon'}));
if (cloudManager.hasAoDEntitlementAndIsEnabled)
game.cartography.worldMaps.getObjectByID('melvorAoD:Melvor').pointsOfInterest.filter(x => search(x)).forEach(poi => results.push({item: poi, icon: 'POIIcon'}));
results.map(x => `*{{${x.icon}|${x.item.name}}}`);
</syntaxhighlight>