Anonymous

Template:Disambiguation/doc: Difference between revisions

From Melvor Idle
Improved EquipmentTableFromList output in script
(Fixed foods being duplicated. Added the starting 2 headers for equipment table template)
(Improved EquipmentTableFromList output in script)
Line 8: Line 8:
<syntaxhighlight lang="javascript" line>
<syntaxhighlight lang="javascript" line>
// Settings //
// Settings //
let searchTerm = 'Sand'; // The proper capitalization of the search term
let searchTerm = 'Siren'; // The proper capitalization of the search term
let returnEquipmentTemplate = false; // returns a template for {{EquipmentTableFromList}} instead
let returnEquipmentTemplate = false; // true returns a template for {{EquipmentTableFromList}} instead
// End of Settings //
// End of Settings //
let lcSearchTerm = searchTerm.toLowerCase();
let lcSearchTerm = searchTerm.toLowerCase();
Line 28: Line 28:
}
}
let results = [];
let results = [];
if (returnEquipmentTemplate) results.push(`{{V|${gameVersion.substr(1)}}}\n\n==${searchTerm} Equipment==\n===Weapons===\n{{EquipmentTableFromList`);
if (returnEquipmentTemplate) results.push(`{{V|${gameVersion.substr(1)}}}\n\n==${searchTerm} Equipment==\n===Melee Weapons===\n{{EquipmentTableFromList\n\n}}\n===Ranged Weapons and Ammo===\n{{EquipmentTableFromList\n\n}}\n===Armour===\n{{EquipmentTableFromList`);
if (!returnEquipmentTemplate) results.push(`{{Disam}}{{V|${gameVersion.substr(1)}}}\n`, `'''${searchTerm}''' may refer to:`);
if (!returnEquipmentTemplate) results.push(`{{Disam}}{{V|${gameVersion.substr(1)}}}\n`, `'''${searchTerm}''' may refer to:`);
pushResults({arr: game.items.weapons.filter(x => search(x) && !x.name.includes('Arrow')), header: '===Equipment===', iconType: 'ItemIcon'});
pushResults({arr: game.items.weapons.filter(x => search(x) && !x.validSlots.includes('Quiver')), header: '===Equipment===', iconType: 'ItemIcon'});
pushResults({arr: game.items.equipment.filter(x => search(x) && !(x instanceof WeaponItem) && !x.name.includes('Arrow')), header: '===Equipment===', iconType: 'ItemIcon'});
pushResults({arr: game.items.equipment.filter(x => search(x) && x.validSlots.includes('Quiver')), header: '===Equipment===', iconType: 'ItemIcon'});
pushResults({arr: game.items.equipment.filter(x => search(x) && x.name.includes('Arrow')), header: '===Equipment===', iconType: 'ItemIcon'});
pushResults({arr: game.items.equipment.filter(x => search(x) && !(x instanceof WeaponItem) && !x.validSlots.includes('Quiver')), header: '===Equipment===', iconType: 'ItemIcon'});
pushResults({arr: game.items.filter(x => x.validSlots === undefined && !(x instanceof OpenableItem) && !(x instanceof BoneItem) && !(x instanceof FoodItem) && search(x)), header: '===Items===', iconType: 'ItemIcon'});
pushResults({arr: game.items.filter(x => x.validSlots === undefined && !(x instanceof OpenableItem) && !(x instanceof BoneItem) && !(x instanceof FoodItem) && search(x)), header: '===Items===', iconType: 'ItemIcon'});
pushResults({arr: game.items.openables.filter(x => search(x)), header: '===Openables===', iconType: 'ItemIcon'});
pushResults({arr: game.items.openables.filter(x => search(x)), header: '===Openables===', iconType: 'ItemIcon'});