Template:Disambiguation/doc: Difference between revisions

Updated script
m (Added expansion icons into output results)
(Updated script)
Line 3: Line 3:
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 with expansion icons. 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.
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 with expansion icons.


This may result in some duplicates between Icons and Shop Purchases, such as Iron Sieve which is both an Item and Purchase.
This may result in some duplicates between Icons and Shop Purchases, such as Iron Sieve which is both an Item and Purchase.
<syntaxhighlight lang="javascript" line>
<syntaxhighlight lang="javascript" line>
let searchTerm = ''.toLowerCase();
let searchTerm = 'Mirror';
 
let lcSearchTerm = searchTerm.toLowerCase();
const search = (obj) => obj.name.toLowerCase().includes(searchTerm);
const search = (obj) => obj.name.toLowerCase().includes(lcSearchTerm);
let results = [];
const wikiIcon = (obj, icon) => `*${obj.namespace?.includes('TotH') ? '{{TotH}}' : obj.namespace?.includes('AoD') ? '{{AoD}}' : ''}{{${icon}|${obj.name}}}`
game.items.filter(x => search(x)).forEach(item => results.push({item: item, icon: 'ItemIcon'}));
let results = [`{{V|${gameVersion.substr(1)}}}{{Disam}}`, '', `'''${searchTerm}''' may refer to:`, '===Equipment==='];
game.monsters.filter(x => search(x)).forEach(monster => results.push({item: monster, icon: 'MonsterIcon'}));
game.items.equipment.filter(x => search(x)).forEach(item => results.push(wikiIcon(item, 'ItemIcon')));
game.skills.filter(x => search(x)).forEach(skill => results.push({item: skill, icon: 'Skill'}));
results.push(`===Items===`);
game.standardSpells.filter(x => search(x)).forEach(spell => results.push({item: spell, icon: 'SpellIcon'})); // In v1.3, these are
game.items.filter(x => x.validSlots === undefined && !(x instanceof OpenableItem) && !(x instanceof BoneItem) && !(x instanceof FoodItem) && search(x)).forEach(item => results.push(wikiIcon(item, 'ItemIcon')));
game.ancientSpells.filter(x => search(x)).forEach(spell => results.push({item: spell, icon: 'SpellIcon'})); // condensed into
results.push(`===Openables===`);
game.archaicSpells.filter(x => search(x)).forEach(spell => results.push({item: spell, icon: 'SpellIcon'})); // game.attackSpells
game.items.openables.filter(x => search(x)).forEach(item => results.push(wikiIcon(item, 'ItemIcon')));
game.curseSpells.filter(x => search(x)).forEach(spell => results.push({item: spell, icon: 'SpellIcon'}));
results.push(`===Bones===`);
game.auroraSpells.filter(x => search(x)).forEach(spell => results.push({item: spell, icon: 'SpellIcon'}));
game.items.bones.filter(x => search(x)).forEach(item => results.push(wikiIcon(item, 'ItemIcon')));
game.shop.purchases.filter(x => search(x)).forEach(purchase => results.push({item: purchase, icon: 'UpgradeIcon'}));
results.push(`===Food===`);
game.pets.filter(x => search(x)).forEach(pet => results.push({item: pet, icon: 'PetIcon'}));
game.items.food.filter(x => search(x)).forEach(item => results.push(wikiIcon(item, 'ItemIcon')));
game.prayers.filter(x => search(x)).forEach(prayer => results.push({item: prayer, icon: 'PrayerIcon'}));
results.push(`===Combat===`);
game.combatAreas.filter(x => search(x)).forEach(area => results.push({item: area, icon: 'ZoneIcon'}));
game.monsters.filter(x => search(x)).forEach(monster => results.push(wikiIcon(monster, 'MonsterIcon')));
game.slayerAreas.filter(x => search(x)).forEach(area => results.push({item: area, icon: 'ZoneIcon'}));
game.combatAreas.filter(x => search(x)).forEach(area => results.push(wikiIcon(area, 'ZoneIcon')));
game.dungeons.filter(x => search(x)).forEach(area => results.push({item: area, icon: 'ZoneIcon'}));
game.slayerAreas.filter(x => search(x)).forEach(area => results.push(wikiIcon(area, 'ZoneIcon')));
game.astrology.actions.filter(x => search(x)).forEach(constellation => results.push({item: constellation, icon: 'ConstellationIcon'}));
game.dungeons.filter(x => search(x)).forEach(area => results.push(wikiIcon(area, 'ZoneIcon')));
game.township.buildings.filter(x => search(x)).forEach(building => results.push({item: building, icon: 'TownshipIcon'}));
results.push(`===Spells===`);
game.township.seasons.filter(x => search(x)).forEach(season => results.push({item: season, icon: 'TownshipIcon'}));
game.standardSpells.filter(x => search(x)).forEach(spell => results.push(wikiIcon(spell, 'SpellIcon'))); // In v1.3, these are
game.township.biomes.filter(x => search(x)).forEach(biome => results.push({item: biome, icon: 'TownshipIcon'}));
game.ancientSpells.filter(x => search(x)).forEach(spell => results.push(wikiIcon(spell, 'SpellIcon'))); // condensed into
game.township.resources.filter(x => search(x)).forEach(resource => results.push({item: resource, icon: 'TownshipIcon'}));
game.archaicSpells.filter(x => search(x)).forEach(spell => results.push(wikiIcon(spell, 'SpellIcon'))); // game.attackSpells
game.agility.actions.filter(x => search(x)).forEach(obstacle => results.push({item: obstacle, icon: 'AgilityIcon'}));
game.curseSpells.filter(x => search(x)).forEach(spell => results.push(wikiIcon(spell, 'SpellIcon')));
game.auroraSpells.filter(x => search(x)).forEach(spell => results.push(wikiIcon(spell, 'SpellIcon')));
results.push(`===Purchases===`);
game.shop.purchases.filter(x => search(x)).forEach(purchase => results.push(wikiIcon(purchase, 'UpgradeIcon')));
results.push(`===Prayers===`);
game.prayers.filter(x => search(x)).forEach(prayer => results.push(wikiIcon(prayer, 'PrayerIcon')));
results.push(`===Township===`);
game.township.buildings.filter(x => search(x)).forEach(building => results.push(wikiIcon(building, 'TownshipIcon')));
game.township.seasons.filter(x => search(x)).forEach(season => results.push(wikiIcon(season, 'TownshipIcon')));
game.township.biomes.filter(x => search(x)).forEach(biome => results.push(wikiIcon(biome, 'TownshipIcon')));
game.township.resources.filter(x => search(x)).forEach(resource => results.push(wikiIcon(resource, 'TownshipIcon')));
results.push(`===Others===`);
game.skills.filter(x => search(x)).forEach(skill => results.push(wikiIcon(skill, 'Skill')));
game.pets.filter(x => search(x)).forEach(pet => results.push(wikiIcon(pet, 'PetIcon')));
game.astrology.actions.filter(x => search(x)).forEach(constellation => results.push(wikiIcon(constellation, 'ConstellationIcon')));
game.agility.actions.filter(x => search(x)).forEach(obstacle => results.push(wikiIcon(obstacle, 'AgilityIcon')));
if (cloudManager.hasAoDEntitlementAndIsEnabled)
if (cloudManager.hasAoDEntitlementAndIsEnabled)
game.cartography.worldMaps.getObjectByID('melvorAoD:Melvor').pointsOfInterest.filter(x => search(x)).forEach(poi => results.push({item: poi, icon: 'POIIcon'}));
game.cartography.worldMaps.getObjectByID('melvorAoD:Melvor').pointsOfInterest.filter(x => search(x)).forEach(poi => results.push(wikiIcon(poi, 'POIIcon')));
results.map(x => `*${x.item.namespace?.includes('TotH') ? '{{TotH}}' : x.item.namespace?.includes('AoD') ? '{{AoD}}' : ''}{{${x.icon}|${x.item.name}}}`);
let outputString = ``;
results.forEach((str) => { outputString += `${str}\n` });
console.log(outputString);
</syntaxhighlight>
</syntaxhighlight>