4,683
edits
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 | 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( | 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( | let results = [`{{V|${gameVersion.substr(1)}}}{{Disam}}`, '', `'''${searchTerm}''' may refer to:`, '===Equipment===']; | ||
game. | game.items.equipment.filter(x => search(x)).forEach(item => results.push(wikiIcon(item, 'ItemIcon'))); | ||
game. | results.push(`===Items===`); | ||
game. | 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. | results.push(`===Openables===`); | ||
game. | game.items.openables.filter(x => search(x)).forEach(item => results.push(wikiIcon(item, 'ItemIcon'))); | ||
game. | results.push(`===Bones===`); | ||
game. | game.items.bones.filter(x => search(x)).forEach(item => results.push(wikiIcon(item, 'ItemIcon'))); | ||
game. | results.push(`===Food===`); | ||
game. | game.items.food.filter(x => search(x)).forEach(item => results.push(wikiIcon(item, 'ItemIcon'))); | ||
game. | results.push(`===Combat===`); | ||
game. | game.monsters.filter(x => search(x)).forEach(monster => results.push(wikiIcon(monster, 'MonsterIcon'))); | ||
game. | game.combatAreas.filter(x => search(x)).forEach(area => results.push(wikiIcon(area, 'ZoneIcon'))); | ||
game. | game.slayerAreas.filter(x => search(x)).forEach(area => results.push(wikiIcon(area, 'ZoneIcon'))); | ||
game. | game.dungeons.filter(x => search(x)).forEach(area => results.push(wikiIcon(area, 'ZoneIcon'))); | ||
game.township.buildings.filter(x => search(x)).forEach(building => results.push( | results.push(`===Spells===`); | ||
game.township.seasons.filter(x => search(x)).forEach(season => results.push( | 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( | 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( | 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( | 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( | game.cartography.worldMaps.getObjectByID('melvorAoD:Melvor').pointsOfInterest.filter(x => search(x)).forEach(poi => results.push(wikiIcon(poi, 'POIIcon'))); | ||
results. | let outputString = ``; | ||
results.forEach((str) => { outputString += `${str}\n` }); | |||
console.log(outputString); | |||
</syntaxhighlight> | </syntaxhighlight> |