4,581
edits
m (Newlined version template) |
(Cleaned up script and support EffectIcon) |
||
Line 17: | Line 17: | ||
const wikiIcon = (item, icon, extras) => { | const wikiIcon = (item, icon, extras) => { | ||
if (!returnEquipmentTemplate) | if (!returnEquipmentTemplate) | ||
return `*${item.namespace.includes('TotH') ? '{{TotH}}' : item.namespace.includes('AoD') ? '{{AoD}}' : item.namespace.includes('ItA') ? '{{ItA}}' : ''}{{${icon}|${item.name}${extras}}}`; | return `* ${item.namespace.includes('TotH') ? '{{TotH}}' : item.namespace.includes('AoD') ? '{{AoD}}' : item.namespace.includes('ItA') ? '{{ItA}}' : ''} {{${icon}|${item.name}${extras}}}`; | ||
return item.name; | return `|${item.name}`; | ||
} | } | ||
const pushResults = (arr, header, icon, extras='') => { | const pushResults = (arr, header, icon, extras='') => { | ||
if (arr.length > 0 && !returnEquipmentTemplate && !results.includes(header)) | if (arr.length > 0 && !returnEquipmentTemplate && !results.includes(header)) | ||
results | results += header; | ||
arr.forEach(item => { | arr.forEach(item => { | ||
if (!returnEquipmentTemplate || item.validSlots !== undefined) | if (!returnEquipmentTemplate || item.validSlots !== undefined) | ||
results | results += `\n${wikiIcon(item, icon, extras)}`; | ||
}); | }); | ||
} | } | ||
let results = | let results = ''; | ||
if (returnEquipmentTemplate) 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 | 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')), '==Equipment==', 'ItemIcon'); | 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')), '==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')), '==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)), '==Items==', '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)), '==Openables==', 'ItemIcon'); | pushResults(game.items.openables.filter(x => search(x)), '\n== Openables ==', 'ItemIcon'); | ||
pushResults(game.items.bones.filter(x => search(x)), '==Bones==', 'ItemIcon'); | pushResults(game.items.bones.filter(x => search(x)), '\n== Bones ==', 'ItemIcon'); | ||
pushResults(game.items.food.filter(x => search(x)), '==Food==', 'ItemIcon'); | pushResults(game.items.food.filter(x => search(x)), '\n== Food ==', 'ItemIcon'); | ||
pushResults(game.monsters.filter(x => search(x)), '==Combat==', 'MonsterIcon'); | pushResults(game.monsters.filter(x => search(x)), '\n== Combat ==', 'MonsterIcon'); | ||
pushResults(game.combatAreas.filter(x => search(x)), '==Combat==', 'ZoneIcon'); | 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)), '==Spells==', 'SpellIcon'); | 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)), '==Purchases==', 'UpgradeIcon'); | pushResults(game.shop.purchases.filter(x => search(x)), '\n== Purchases ==', 'UpgradeIcon'); | ||
pushResults(game.prayers.filter(x => search(x)), '==Prayers==', 'PrayerIcon'); | 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)), '==Township==', 'TownshipIcon'); | 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)), '==Others==', 'Skill'); | pushResults(game.skills.filter(x => search(x)), '\n== Others ==', 'Skill'); | ||
pushResults(game.pets.filter(x => search(x)), '==Others==', 'PetIcon'); | pushResults(game.pets.filter(x => search(x)), '\n== Others ==', 'PetIcon'); | ||
pushResults(game.astrology.actions.filter(x => search(x)), '==Others==', 'ConstellationIcon'); | pushResults(game.astrology.actions.filter(x => search(x)), '\n== Others ==', 'ConstellationIcon'); | ||
pushResults(game.agility.actions.filter(x => search(x)), '==Others==', 'AgilityIcon'); | pushResults(game.agility.actions.filter(x => search(x)), '\n== Others ==', 'AgilityIcon'); | ||
pushResults(game.thieving.actions.filter(x => search(x)), '==Others==', 'Icon', '|type=thieving'); | 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) | ||
pushResults(game.cartography.worldMaps.getObjectByID('melvorAoD:Melvor').pointsOfInterest.filter(x => search(x)), '==Others==', 'POIIcon' | 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); | |||
if (returnEquipmentTemplate) | console.log(results); | ||
self.nw?.Clipboard.get().set ? self.nw?.Clipboard?.get().set( | |||
console.log( | |||
notifyPlayer(game.attack, `Copied results for ${searchTerm} to clipboard`, 'success', 0); | notifyPlayer(game.attack, `Copied results for ${searchTerm} to clipboard`, 'success', 0); | ||
</syntaxhighlight> | </syntaxhighlight> |