Template:Disambiguation/doc: Difference between revisions

From Melvor Idle
mNo edit summary
m (Remove double spacing when there's no expansion icon)
(26 intermediate revisions by 2 users not shown)
Line 1: Line 1:
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.
Template that is used on [[:Category:Disambiguation|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]]
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.
The below script will search all current [[Template:Icon|Icon Templates]] in v1.2.2 (except for Synergies, Spellbooks (not Spells) 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 ItemIcons and UpdateIcons, such as Iron Sieve which is both an Item and Purchase.
 
To use the script, copy and paste it into the console and change the <code>searchTerm</code> to the disambiguation page you're about to create. Upon hitting enter, the outputs will be pasted into the console while also being copied to the clipboard. If the results look good (not a single item or there's a bunch of random items with 1 clear choice for what the user was looking for) then begin creating the disambiguation page. The results will need a manual check before creating the page. Items that include 'Dusty' should not be included with 'Dust' however 'Stardust' is fine due to how relevant the item is. Certain category names may be changed if that category only contains 1 type of object, such as 'Combat' to 'Combat Areas' or 'Others' to 'Points of Interest'.
 
For <code>returnEquipmentTemplate</code>, see [[Template:EquipmentTableFromList/doc]].


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();
// Settings //
 
let searchTerm = 'Siren'; // The proper capitalization of the search term
const search = (obj) => obj.name.toLowerCase().includes(searchTerm);
let returnEquipmentTemplate = false; // returns a template for {{EquipmentTableFromList}} instead
let results = [];
// End of Settings //
game.items.filter(x => search(x)).forEach(item => results.push({item: item, icon: 'ItemIcon'}));
const search = (item) => !item.isModded && item.name.toLowerCase().includes(searchTerm.toLowerCase());
game.monsters.filter(x => search(x)).forEach(monster => results.push({item: monster, icon: 'MonsterIcon'}));
const wikiIcon = (item, icon, extras) => {
game.skills.filter(x => search(x)).forEach(skill => results.push({item: skill, icon: 'Skill'}));
if (!returnEquipmentTemplate)
game.standardSpells.filter(x => search(x)).forEach(spell => results.push({item: spell, icon: 'SpellIcon'})); // In v1.3, these are
return `*${item.namespace.includes('TotH') ? ' {{TotH}}' : item.namespace.includes('AoD') ? ' {{AoD}}' : item.namespace.includes('ItA') ? ' {{ItA}}' : ''} {{${icon}|${item.name}${extras}}}`;
game.ancientSpells.filter(x => search(x)).forEach(spell => results.push({item: spell, icon: 'SpellIcon'})); // condensed into
return `|${item.name}`;
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'}));
const pushResults = (arr, header, icon, extras='') => {
game.auroraSpells.filter(x => search(x)).forEach(spell => results.push({item: spell, icon: 'SpellIcon'}));
if (arr.length > 0 && !returnEquipmentTemplate && !results.includes(header))
game.shop.purchases.filter(x => search(x)).forEach(purchase => results.push({item: purchase, icon: 'UpgradeIcon'}));
results += header;
game.pets.filter(x => search(x)).forEach(pet => results.push({item: pet, icon: 'PetIcon'}));
arr.forEach(item => {
game.prayers.filter(x => search(x)).forEach(prayer => results.push({item: prayer, icon: 'PrayerIcon'}));
if (!returnEquipmentTemplate || item.validSlots !== undefined)
game.combatAreas.filter(x => search(x)).forEach(area => results.push({item: area, icon: 'ZoneIcon'}));
results += `\n${wikiIcon(item, icon, extras)}`;
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'}));
let results = '';
game.township.buildings.filter(x => search(x)).forEach(building => results.push({item: building, icon: 'TownshipIcon'}));
if (returnEquipmentTemplate) results += `{{UserContentVersion|${gameVersion.substr(1)}}}\n\n= ${searchTerm} Equipment =\n== Melee Weapons ==\n{{EquipmentTableFromList\n\n}}\n== Ranged Weapons & Ammo ==\n{{EquipmentTableFromList\n\n}}\n== Armour ==\n{{EquipmentTableFromList\n|includeModifiers=false`;
game.township.seasons.filter(x => search(x)).forEach(season => results.push({item: season, icon: 'TownshipIcon'}));
if (!returnEquipmentTemplate) results += `{{Disam}}\n{{UserContentVersion|${gameVersion.substr(1)}}}\n\n'''${searchTerm}''' may refer to:`;
game.township.biomes.filter(x => search(x)).forEach(biome => results.push({item: biome, icon: 'TownshipIcon'}));
pushResults(game.items.weapons.filter(x => search(x) && !x.validSlots.includes('Quiver')), '\n== Equipment ==', 'ItemIcon');
game.township.resources.filter(x => search(x)).forEach(resource => results.push({item: resource, icon: 'TownshipIcon'}));
pushResults(game.items.equipment.filter(x => search(x) && x.validSlots.includes('Quiver')), '\n== Equipment ==', 'ItemIcon');
game.agility.actions.filter(x => search(x)).forEach(obstacle => results.push({item: obstacle, icon: 'AgilityIcon'}));
pushResults(game.items.equipment.filter(x => search(x) && !(x instanceof WeaponItem) && !x.validSlots.includes('Quiver')), '\n== Equipment ==', 'ItemIcon');
pushResults(game.items.filter(x => x.validSlots == undefined && !(x instanceof OpenableItem) && !(x instanceof BoneItem) && !(x instanceof FoodItem) && search(x)), '\n== Items ==', 'ItemIcon');
pushResults(game.items.openables.filter(x => search(x)), '\n== Openables ==', 'ItemIcon');
pushResults(game.items.bones.filter(x => search(x)), '\n== Bones ==', 'ItemIcon');
pushResults(game.items.food.filter(x => search(x)), '\n== Food ==', 'ItemIcon');
pushResults(game.monsters.filter(x => search(x)), '\n== Combat ==', 'MonsterIcon');
pushResults(game.combatAreas.filter(x => search(x)), '\n== Combat ==', 'ZoneIcon');
pushResults([...game.attackSpells.allObjects, ...game.curseSpells.allObjects, ...game.auroraSpells.allObjects, ...game.altMagic.actions.allObjects].filter(x => search(x)), '\n== Spells ==', 'SpellIcon');
pushResults(game.shop.purchases.filter(x => search(x)), '\n== Purchases ==', 'UpgradeIcon');
pushResults(game.prayers.filter(x => search(x)), '\n== Prayers ==', 'PrayerIcon');
pushResults([...game.township.buildings.allObjects, ...game.township.seasons.allObjects, ...game.township.biomes.allObjects, ...game.township.resources.allObjects].filter(x => search(x)), '\n== Township ==', 'TownshipIcon');
pushResults(game.skills.filter(x => search(x)), '\n== Others ==', 'Skill');
pushResults(game.pets.filter(x => search(x)), '\n== Others ==', 'PetIcon');
pushResults(game.astrology.actions.filter(x => search(x)), '\n== Others ==', 'ConstellationIcon');
pushResults(game.agility.actions.filter(x => search(x)), '\n== Others ==', 'AgilityIcon');
pushResults(game.thieving.actions.filter(x => search(x)), '\n== Others ==', 'Icon', '|type=thieving');
pushResults(game.combatEffects.allObjects.filter(x => search(x)), '\n== Others ==', 'EffectIcon');
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'}));
pushResults(game.cartography.worldMaps.getObjectByID('melvorAoD:Melvor').pointsOfInterest.filter(x => search(x)), '\n== Others ==', 'POIIcon');
results.map(x => `*{{${x.icon}|${x.item.name}}}`);
if (returnEquipmentTemplate) results += '\n}}';
self.nw?.Clipboard.get().set ? self.nw?.Clipboard?.get().set(results, 'text') : copy(results);
console.log(results);
notifyPlayer(game.attack, `Copied results for ${searchTerm} to clipboard`, 'success', 0);
</syntaxhighlight>
</syntaxhighlight>

Revision as of 13:45, 7 September 2024

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

The below script will search all current Icon Templates in v1.2.2 (except for Synergies, Spellbooks (not Spells) and Currencies) for the given searchTerm then output an array of the results in valid Icon Template format with expansion icons. This may result in some duplicates between ItemIcons and UpdateIcons, such as Iron Sieve which is both an Item and Purchase.

To use the script, copy and paste it into the console and change the searchTerm to the disambiguation page you're about to create. Upon hitting enter, the outputs will be pasted into the console while also being copied to the clipboard. If the results look good (not a single item or there's a bunch of random items with 1 clear choice for what the user was looking for) then begin creating the disambiguation page. The results will need a manual check before creating the page. Items that include 'Dusty' should not be included with 'Dust' however 'Stardust' is fine due to how relevant the item is. Certain category names may be changed if that category only contains 1 type of object, such as 'Combat' to 'Combat Areas' or 'Others' to 'Points of Interest'.

For returnEquipmentTemplate, see Template:EquipmentTableFromList/doc.

// Settings //
let searchTerm = 'Siren'; // The proper capitalization of the search term
let returnEquipmentTemplate = false; // returns a template for {{EquipmentTableFromList}} instead
// End of Settings //
const search = (item) => !item.isModded && item.name.toLowerCase().includes(searchTerm.toLowerCase());
const wikiIcon = (item, icon, extras) => {
	if (!returnEquipmentTemplate)
		return `*${item.namespace.includes('TotH') ? ' {{TotH}}' : item.namespace.includes('AoD') ? ' {{AoD}}' : item.namespace.includes('ItA') ? ' {{ItA}}' : ''} {{${icon}|${item.name}${extras}}}`;
	return `|${item.name}`;
}
const pushResults = (arr, header, icon, extras='') => {
	if (arr.length > 0 && !returnEquipmentTemplate && !results.includes(header))
		results += header;
	arr.forEach(item => {
		if (!returnEquipmentTemplate || item.validSlots !== undefined)
			results += `\n${wikiIcon(item, icon, extras)}`;
	});
}
let results = '';
if (returnEquipmentTemplate) results += `{{UserContentVersion|${gameVersion.substr(1)}}}\n\n= ${searchTerm} Equipment =\n== Melee Weapons ==\n{{EquipmentTableFromList\n\n}}\n== Ranged Weapons & Ammo ==\n{{EquipmentTableFromList\n\n}}\n== Armour ==\n{{EquipmentTableFromList\n|includeModifiers=false`;
if (!returnEquipmentTemplate) results += `{{Disam}}\n{{UserContentVersion|${gameVersion.substr(1)}}}\n\n'''${searchTerm}''' may refer to:`;
pushResults(game.items.weapons.filter(x => search(x) && !x.validSlots.includes('Quiver')), '\n== Equipment ==', 'ItemIcon');
pushResults(game.items.equipment.filter(x => search(x) && x.validSlots.includes('Quiver')), '\n== Equipment ==', 'ItemIcon');
pushResults(game.items.equipment.filter(x => search(x) && !(x instanceof WeaponItem) && !x.validSlots.includes('Quiver')), '\n== Equipment ==', 'ItemIcon');
pushResults(game.items.filter(x => x.validSlots == undefined && !(x instanceof OpenableItem) && !(x instanceof BoneItem) && !(x instanceof FoodItem) && search(x)), '\n== Items ==', 'ItemIcon');
pushResults(game.items.openables.filter(x => search(x)), '\n== Openables ==', 'ItemIcon');
pushResults(game.items.bones.filter(x => search(x)), '\n== Bones ==', 'ItemIcon');
pushResults(game.items.food.filter(x => search(x)), '\n== Food ==', 'ItemIcon');
pushResults(game.monsters.filter(x => search(x)), '\n== Combat ==', 'MonsterIcon');
pushResults(game.combatAreas.filter(x => search(x)), '\n== Combat ==', 'ZoneIcon');
pushResults([...game.attackSpells.allObjects, ...game.curseSpells.allObjects, ...game.auroraSpells.allObjects, ...game.altMagic.actions.allObjects].filter(x => search(x)), '\n== Spells ==', 'SpellIcon');
pushResults(game.shop.purchases.filter(x => search(x)), '\n== Purchases ==', 'UpgradeIcon');
pushResults(game.prayers.filter(x => search(x)), '\n== Prayers ==', 'PrayerIcon');
pushResults([...game.township.buildings.allObjects, ...game.township.seasons.allObjects, ...game.township.biomes.allObjects, ...game.township.resources.allObjects].filter(x => search(x)), '\n== Township ==', 'TownshipIcon');
pushResults(game.skills.filter(x => search(x)), '\n== Others ==', 'Skill');
pushResults(game.pets.filter(x => search(x)), '\n== Others ==', 'PetIcon');
pushResults(game.astrology.actions.filter(x => search(x)), '\n== Others ==', 'ConstellationIcon');
pushResults(game.agility.actions.filter(x => search(x)), '\n== Others ==', 'AgilityIcon');
pushResults(game.thieving.actions.filter(x => search(x)), '\n== Others ==', 'Icon', '|type=thieving');
pushResults(game.combatEffects.allObjects.filter(x => search(x)), '\n== Others ==', 'EffectIcon');
if (cloudManager.hasAoDEntitlementAndIsEnabled)
	pushResults(game.cartography.worldMaps.getObjectByID('melvorAoD:Melvor').pointsOfInterest.filter(x => search(x)), '\n== Others ==', 'POIIcon');
if (returnEquipmentTemplate) results += '\n}}';
self.nw?.Clipboard.get().set ? self.nw?.Clipboard?.get().set(results, 'text') : copy(results);
console.log(results);
notifyPlayer(game.attack, `Copied results for ${searchTerm} to clipboard`, 'success', 0);