diff options
Diffstat (limited to 'Data/BuiltIn/Libraries/lua-addons/addons/SpellCheck')
3 files changed, 166 insertions, 0 deletions
diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/SpellCheck/README.md b/Data/BuiltIn/Libraries/lua-addons/addons/SpellCheck/README.md new file mode 100644 index 0000000..15b7180 --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/SpellCheck/README.md @@ -0,0 +1,24 @@ +#SpellCheck + +This addon lists spells you haven't unlocked yet. + +##Usage + +//spellcheck whm | blm | smn | nin | brd | blu | geo | tru + +##Credits +shinpad, trv, Arcon et al. at +http://forums.windower.net/index.php?/topic/938-blu-spell-checklist-script/ +and +http://forums.windower.net/index.php?/topic/973-trust-checklist-script/ + +##Release Notes + +###1.0.2 - 2015-12-15 +* Added Sleepga I/II spell exception as the spells were listed in spells.lua twice. + +###1.0.1 - 2015-11-21 +* Added spell exceptions. + +###1.0.0 - 2015-11-15 +* Initial release. diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/SpellCheck/SpellCheck.lua b/Data/BuiltIn/Libraries/lua-addons/addons/SpellCheck/SpellCheck.lua new file mode 100644 index 0000000..0d77066 --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/SpellCheck/SpellCheck.lua @@ -0,0 +1,117 @@ +--Copyright © 2015, Damien Dennehy +--All rights reserved. + +--Redistribution and use in source and binary forms, with or without +--modification, are permitted provided that the following conditions are met: + +-- * Redistributions of source code must retain the above copyright +-- notice, this list of conditions and the following disclaimer. +-- * Redistributions in binary form must reproduce the above copyright +-- notice, this list of conditions and the following disclaimer in the +-- documentation and/or other materials provided with the distribution. +-- * Neither the name of SpellCheck nor the +-- names of its contributors may be used to endorse or promote products +-- derived from this software without specific prior written permission. + +--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +--ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +--WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +--DISCLAIMED. IN NO EVENT SHALL DAMIEN DENNEHY BE LIABLE FOR ANY +--DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +--(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +--LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +--ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +--(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +--SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +_addon.name = 'SpellCheck' +_addon.author = 'Zubis' +_addon.version = '1.0.2' +_addon.command = 'SpellCheck' + +require('sets') +require('tables') +res = require('resources') + +require('SpellExceptions') + +--Declare valid spell types +spell_type = {whm='WhiteMagic',blm='BlackMagic',smn='SummonerPact',nin='Ninjutsu',brd='BardSong',blu='BlueMagic',geo='Geomancy',tru='Trust'} + +--Declare friendly name of spell types for chat output +display_spell_type = {whm='White Magic',blm='Black Magic',smn='Summoner',nin='Ninjutsu',brd='Bard',blu='Blue Magic',geo='Geomancy',tru='Trust'} + +--Register the base //SpellCheck command +windower.register_event('addon command',function (command, ...) + command = command and command:lower() or 'help' + if command == 'help' or command == 'h' or command == '?' then + display_help() + elseif spell_type[command] == nil then + display_error(command) + else + display_spell_count(command) + end +end) + +--Display a basic help section +function display_help() + windower.add_to_chat(7, _addon.name .. ' v.' .. _addon.version) + windower.add_to_chat(7, 'Usage: //spellcheck whm | blm | smn | nin | brd | blu | geo | tru') + windower.add_to_chat(7, 'Sample: //spellcheck whm') +end + +--Display error based on invalid selection +function display_error(command) + windower.add_to_chat(7, _addon.name .. ' v.' .. _addon.version) + windower.add_to_chat(7, 'Error: ' .. command .. ' is not a valid option.') + windower.add_to_chat(7, 'Usage: //spellcheck whm | blm | smn | nin | brd | blu | geo | tru') +end + +--Get spells +function display_spell_count(command) + + missing_spells_len = 0 + missing_spell_names = {} + + --Get all, current and missing spells + all_spells = res.spells:type(spell_type[command]):keyset() + current_spells = T(windower.ffxi.get_spells()):filter(boolean._true):keyset() + + missing_spells = all_spells - current_spells + current_spells = all_spells * current_spells + + --Add missing spells to table for sorting + for spell in missing_spells:it() do + --Trust and spells must be processed separately + if command == 'tru' then + --Only include non Unity trusts + if not res.spells[spell].name:endswith('(UC)') then + missing_spells_len = missing_spells_len + 1 + table.insert(missing_spell_names, res.spells[spell].name) + end + else + --Add to missing spell list only if it's a valid spell + --And it's not in the spell exception list + if not table.empty(res.spells[spell].levels) and spell_exceptions[res.spells[spell].id] == nil then + missing_spells_len = missing_spells_len + 1 + table.insert(missing_spell_names, res.spells[spell].name) + end + end + end + + --Sort missing spells by name + table.sort(missing_spell_names) + + --If there are missing spells, display that they are about to be listed + if missing_spells_len > 0 then + windower.add_to_chat(7, 'SpellCheck: Listing missing ' .. display_spell_type[command] .. ' spells...') + end + + --List all missing spell names + for i, spell in ipairs(missing_spell_names) do + windower.add_to_chat(7, ' - Missing \'' .. spell .. '\'') + end + + --Display summary + windower.add_to_chat(7, 'SpellCheck: You are missing ' .. missing_spells_len .. ' ' .. display_spell_type[command] .. ' spells.') +end diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/SpellCheck/SpellExceptions.lua b/Data/BuiltIn/Libraries/lua-addons/addons/SpellCheck/SpellExceptions.lua new file mode 100644 index 0000000..7db8f26 --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/SpellCheck/SpellExceptions.lua @@ -0,0 +1,25 @@ +spell_exceptions = { + [31] = {id=31,en="Banish IV",ja="バニシュIV"}, + [40] = {id=40,en="Banishga III",ja="バニシュガIII"}, + [34] = {id=34,en="Diaga II",ja="ディアガII"}, + [35] = {id=35,en="Diaga III",ja="ディアガIII"}, + [358] = {id=358,en="Hastega",ja="ヘイスガ"}, + [356] = {id=356,en="Paralyga",ja="パライガ"}, + [359] = {id=359,en="Silencega",ja="サイレガ"}, + [357] = {id=357,en="Slowga",ja="スロウガ"}, + [361] = {id=361,en="Blindga",ja="ブライガ"}, + [362] = {id=362,en="Bindga",ja="バインガ"}, + [257] = {id=257,en="Curse",ja="カーズ"}, + [360] = {id=360,en="Dispelga",ja="ディスペガ"}, + [226] = {id=226,en="Poisonga II",ja="ポイゾガII"}, + [256] = {id=256,en="Virus",ja="ウィルス"}, + [244] = {id=244,en="Meteor II",ja="メテオII"}, + [351] = {id=351,en="Dokumori: Ni",ja="毒盛の術:弐"}, + [342] = {id=342,en="Jubaku: Ni",ja="呪縛の術:弐"}, + [349] = {id=349,en="Kurayami: San",ja="暗闇の術:参"}, + [355] = {id=355,en="Tonko: San",ja="遁甲の術:参"}, + [416] = {id=416,en="Cactuar Fugue",ja="サボテンダーフーガ"}, + [407] = {id=407,en="Chocobo Hum",ja="チョコボのハミング"}, + [363] = {id=363,en="Sleepga",ja="スリプガ"}, + [364] = {id=364,en="Sleepga II",ja="スリプガII"} +} |