From 30b8859a2d8335ed9c63c24c4bd2221a9022eb58 Mon Sep 17 00:00:00 2001 From: dtw <362017+dtw@users.noreply.github.com> Date: Sat, 13 Feb 2021 10:23:54 +0000 Subject: [PATCH 1/6] Use logger instead of add_to_chat --- addons/macrochanger/macrochanger.lua | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/addons/macrochanger/macrochanger.lua b/addons/macrochanger/macrochanger.lua index 727f592dd..6eb09e0f5 100644 --- a/addons/macrochanger/macrochanger.lua +++ b/addons/macrochanger/macrochanger.lua @@ -30,6 +30,7 @@ _addon.version = '1.0.0.1' _addon.commands = {'mc','macrochanger'} require('strings') +require('logger') windower.register_event('load', function() globaldisable = 0 @@ -107,7 +108,7 @@ function options_load() RUN = {Book = '20', Page = '1'}, } print('Default settings file created') - windower.add_to_chat(12,'MacroChanger created a settings file and loaded!') + notice('MacroChanger created a settings file and loaded!') else f:close() for curline in io.lines(windower.addon_path..'data/settings.txt') do @@ -119,7 +120,7 @@ function options_load() globaldisable = tonumber(splat[3]) end end - windower.add_to_chat(12,'MacroChanger read from a settings file and loaded!') + notice('MacroChanger read from a settings file and loaded!') end end @@ -135,14 +136,14 @@ windower.register_event('job change',function () end if ((book == 'disabled') or (page == 'disabled')) then - windower.add_to_chat(17, ' Auto Macro Switching Disabled for ' .. job ..'.') + notice('Auto Macro Switching Disabled for ' .. job ..'.') else - windower.add_to_chat(17, ' Changing macros to Book: ' .. book .. ' and Page: ' .. page .. '. Job Changed to ' .. job) + log('Changing macros to Book: ' .. book .. ' and Page: ' .. page .. '. Job Changed to ' .. job) windower.send_command('input /macro book '..book..';wait 0.2;input /macro set '..page..';') end elseif globaldisable == 1 then - windower.add_to_chat(17, ' Auto Macro Switching Disabled for All Jobs.') + notice('Auto Macro Switching Disabled for All Jobs.') end end) @@ -153,16 +154,16 @@ windower.register_event('addon command', function(...) if args[1] == 'disableall' then if args[2] == 'on' then globaldisable = 1 - windower.add_to_chat(17, 'All automated macro switching disabled.') + warning('All automated macro switching disabled.') elseif args[2] == 'off' then globaldisable = 0 - windower.add_to_chat(17, 'Automated macro switching enabled.') + notice('Automated macro switching enabled.') end elseif args[1]:lower() == 'help' then - windower.add_to_chat(17, 'MacroChanger Commands:') - windower.add_to_chat(17, 'disableall [on|off]') - windower.add_to_chat(17, ' on - Disables all automated macro switching') - windower.add_to_chat(17, ' off - Enables all automated macro switching not disabled individually') - windower.add_to_chat(17, ' Resets to what is stored in settings upon unloading of addon. To Permanently change, please change the option in the settings file.') + log('MacroChanger Commands:') + log('disableall [on|off]') + log(' on - Disables all automated macro switching') + log(' off - Enables all automated macro switching not disabled individually') + log('Resets to what is stored in settings upon unloading of addon. To Permanently change, please change the option in the settings file.') end end) From 42ed61c16d2b3b81290263e5bb56b6ccdfbacda6 Mon Sep 17 00:00:00 2001 From: dtw <362017+dtw@users.noreply.github.com> Date: Sat, 13 Feb 2021 10:30:07 +0000 Subject: [PATCH 2/6] Adjust wording ... this is more personal preference, I guess... --- addons/macrochanger/macrochanger.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/macrochanger/macrochanger.lua b/addons/macrochanger/macrochanger.lua index 6eb09e0f5..23af75acc 100644 --- a/addons/macrochanger/macrochanger.lua +++ b/addons/macrochanger/macrochanger.lua @@ -138,7 +138,7 @@ windower.register_event('job change',function () if ((book == 'disabled') or (page == 'disabled')) then notice('Auto Macro Switching Disabled for ' .. job ..'.') else - log('Changing macros to Book: ' .. book .. ' and Page: ' .. page .. '. Job Changed to ' .. job) + log('Job changed to ' .. job .. ' - switched to Book: ' .. book .. ' and Page: ' .. page) windower.send_command('input /macro book '..book..';wait 0.2;input /macro set '..page..';') end elseif globaldisable == 1 then From 4d5c3c3bd77499e98add922227cbca293b71c615 Mon Sep 17 00:00:00 2001 From: dtw <362017+dtw@users.noreply.github.com> Date: Sat, 13 Feb 2021 16:55:40 +0000 Subject: [PATCH 3/6] Whitespace --- addons/macrochanger/macrochanger.lua | 142 +++++++++++++-------------- 1 file changed, 70 insertions(+), 72 deletions(-) diff --git a/addons/macrochanger/macrochanger.lua b/addons/macrochanger/macrochanger.lua index 23af75acc..232ed0967 100644 --- a/addons/macrochanger/macrochanger.lua +++ b/addons/macrochanger/macrochanger.lua @@ -33,7 +33,7 @@ require('strings') require('logger') windower.register_event('load', function() - globaldisable = 0 + globaldisable = 0 macros = { WAR = {Book = '', Page = ''}, MNK = {Book = '', Page = ''}, @@ -58,31 +58,31 @@ windower.register_event('load', function() GEO = {Book = '', Page = ''}, RUN = {Book = '', Page = ''}, } - options_load() + options_load() end) function options_load() - local f = io.open(windower.addon_path..'data/settings.txt', "r") - if f == nil then - local g = io.open(windower.addon_path..'data/settings.txt', "w") - g:write('Release Date: 9:00 PM, 4-01-13\46\n') - g:write('Author Comment: This document is whitespace sensitive, which means that you need the same number of spaces between things as exist in this initial settings file\46\n') - g:write('Author Comment: It looks at the first two words separated by spaces and then takes anything as the value in question if the first two words are relevant\46\n') - g:write('Author Comment: If you ever mess it up so that it does not work, you can just delete it and MacroChanger will regenerate it upon reload\46\n') - g:write('Author Comment: For the output customization lines, simply place the book and page number that you would like to change to upon a job change.\46\n') - g:write('Author Comment: If 2 jobs share a book, you can place the same book number for each job, then put their individual pages.\46\n') - g:write('Author Comment: Example: BLM and SCH both use Macro Book 2: BLM uses page 3. SCH uses page 1.\46\n') - g:write('Author Comment: Put BLM Book: 2, BLM Page: 3, SCH Book: 2, SCH Page: 1.\46\n') - g:write('Author Comment: If you wish to disable auto-macro Changing for a specific job, type "disabled" instead of a book number. (e.g. BLM Book: disabled)\n') - g:write('Author Comment: The design of the settings file is credited to Byrthnoth as well as the creation of the settings file.\n\n\n') - g:write('File Settings: Fill in below\n') - g:write('Disable All: 0\n') - g:write('WAR Book: 1\nWAR Page: 1\nMNK Book: 2\nMNK Page: 1\nWHM Book: 3\nWHM Page: 1\nBLM Book: 4\nBLM Page: 1\nRDM Book: 5\nRDM Page: 1\nTHF Book: 6\nTHF Page: 1\n') - g:write('PLD Book: 7\nPLD Page: 1\nDRK Book: 8\nDRK Page: 1\nBST Book: 9\nBST Page: 1\nBRD Book: 10\nBRD Page: 1\nRNG Book: 11\nRNG Page: 1\nSAM Book: 12\nSAM Page: 1\n') - g:write('NIN Book: 13\nNIN Page: 1\nDRG Book: 14\nDRG Page: 1\nSMN Book: 15\nSMN Page: 1\nBLU Book: 16\nBLU Page: 1\nCOR Book: 17\nCOR Page: 1\nPUP Book: 18\nPUP Page: 1\n') - g:write('DNC Book: 19\nDNC Page: 1\nSCH Book: 20\nSCH Page: 1\nGEO Book: 20\nGEO Page: 1\nRUN Book: 20\nRUN Page: 1\n') - g:close() - DisableAll = 0 + local f = io.open(windower.addon_path..'data/settings.txt', "r") + if f == nil then + local g = io.open(windower.addon_path..'data/settings.txt', "w") + g:write('Release Date: 9:00 PM, 4-01-13\46\n') + g:write('Author Comment: This document is whitespace sensitive, which means that you need the same number of spaces between things as exist in this initial settings file\46\n') + g:write('Author Comment: It looks at the first two words separated by spaces and then takes anything as the value in question if the first two words are relevant\46\n') + g:write('Author Comment: If you ever mess it up so that it does not work, you can just delete it and MacroChanger will regenerate it upon reload\46\n') + g:write('Author Comment: For the output customization lines, simply place the book and page number that you would like to change to upon a job change.\46\n') + g:write('Author Comment: If 2 jobs share a book, you can place the same book number for each job, then put their individual pages.\46\n') + g:write('Author Comment: Example: BLM and SCH both use Macro Book 2: BLM uses page 3. SCH uses page 1.\46\n') + g:write('Author Comment: Put BLM Book: 2, BLM Page: 3, SCH Book: 2, SCH Page: 1.\46\n') + g:write('Author Comment: If you wish to disable auto-macro Changing for a specific job, type "disabled" instead of a book number. (e.g. BLM Book: disabled)\n') + g:write('Author Comment: The design of the settings file is credited to Byrthnoth as well as the creation of the settings file.\n\n\n') + g:write('File Settings: Fill in below\n') + g:write('Disable All: 0\n') + g:write('WAR Book: 1\nWAR Page: 1\nMNK Book: 2\nMNK Page: 1\nWHM Book: 3\nWHM Page: 1\nBLM Book: 4\nBLM Page: 1\nRDM Book: 5\nRDM Page: 1\nTHF Book: 6\nTHF Page: 1\n') + g:write('PLD Book: 7\nPLD Page: 1\nDRK Book: 8\nDRK Page: 1\nBST Book: 9\nBST Page: 1\nBRD Book: 10\nBRD Page: 1\nRNG Book: 11\nRNG Page: 1\nSAM Book: 12\nSAM Page: 1\n') + g:write('NIN Book: 13\nNIN Page: 1\nDRG Book: 14\nDRG Page: 1\nSMN Book: 15\nSMN Page: 1\nBLU Book: 16\nBLU Page: 1\nCOR Book: 17\nCOR Page: 1\nPUP Book: 18\nPUP Page: 1\n') + g:write('DNC Book: 19\nDNC Page: 1\nSCH Book: 20\nSCH Page: 1\nGEO Book: 20\nGEO Page: 1\nRUN Book: 20\nRUN Page: 1\n') + g:close() + DisableAll = 0 macros = { WAR = {Book = '1', Page = '1'}, MNK = {Book = '2', Page = '1'}, @@ -107,63 +107,61 @@ function options_load() GEO = {Book = '20', Page = '1'}, RUN = {Book = '20', Page = '1'}, } - print('Default settings file created') - notice('MacroChanger created a settings file and loaded!') - else - f:close() - for curline in io.lines(windower.addon_path..'data/settings.txt') do - local splat = curline:gsub(':',''):split(' ') - local cmd = '' - if splat[1] and macros[splat[1]:upper()] and splat[2] ~=nil and (splat[2]:lower() == 'book' or splat[2]:lower() == 'page') and splat[3] then - macros[splat[1]:upper()][splat[2]:ucfirst()] = splat[3] -- Instead of a number, this can also be 'disabled' - elseif splat[1] and splat[2] and (splat[1]..' '..splat[2]) == 'disable all' and tonumber(splat[3]) then - globaldisable = tonumber(splat[3]) - end - end - notice('MacroChanger read from a settings file and loaded!') - end + print('Default settings file created') + notice('MacroChanger created a settings file and loaded!') + else + f:close() + for curline in io.lines(windower.addon_path..'data/settings.txt') do + local splat = curline:gsub(':',''):split(' ') + local cmd = '' + if splat[1] and macros[splat[1]:upper()] and splat[2] ~=nil and (splat[2]:lower() == 'book' or splat[2]:lower() == 'page') and splat[3] then + macros[splat[1]:upper()][splat[2]:ucfirst()] = splat[3] -- Instead of a number, this can also be 'disabled' + elseif splat[1] and splat[2] and (splat[1]..' '..splat[2]) == 'disable all' and tonumber(splat[3]) then + globaldisable = tonumber(splat[3]) + end + end + notice('MacroChanger read from a settings file and loaded!') + end end windower.register_event('job change',function () -- Could use the job ID passed into this function, but the addon would have to include the resources library - local job = windower.ffxi.get_player().main_job - local book = '' - local page = '' - if globaldisable == 0 then + local job = windower.ffxi.get_player().main_job + local book = '' + local page = '' + if globaldisable == 0 then if job and macros[job] then - book = macros[job].Book - page = macros[job].Page - end + book = macros[job].Book + page = macros[job].Page + end - if ((book == 'disabled') or (page == 'disabled')) then - notice('Auto Macro Switching Disabled for ' .. job ..'.') - else - log('Job changed to ' .. job .. ' - switched to Book: ' .. book .. ' and Page: ' .. page) - windower.send_command('input /macro book '..book..';wait 0.2;input /macro set '..page..';') - end - elseif globaldisable == 1 then - - notice('Auto Macro Switching Disabled for All Jobs.') - - end + if ((book == 'disabled') or (page == 'disabled')) then + notice('Auto Macro Switching Disabled for ' .. job ..'.') + else + log('Job changed to ' .. job .. ' - switched to Book: ' .. book .. ' and Page: ' .. page) + windower.send_command('input /macro book '..book..';wait 0.2;input /macro set '..page..';') + end + elseif globaldisable == 1 then + notice('Auto Macro Switching Disabled for All Jobs.') + end end) windower.register_event('addon command', function(...) local args = {...} - local mjob = windower.ffxi.get_player().main_job - if args[1] == 'disableall' then - if args[2] == 'on' then - globaldisable = 1 - warning('All automated macro switching disabled.') - elseif args[2] == 'off' then - globaldisable = 0 - notice('Automated macro switching enabled.') - end - elseif args[1]:lower() == 'help' then - log('MacroChanger Commands:') - log('disableall [on|off]') - log(' on - Disables all automated macro switching') - log(' off - Enables all automated macro switching not disabled individually') - log('Resets to what is stored in settings upon unloading of addon. To Permanently change, please change the option in the settings file.') - end + local mjob = windower.ffxi.get_player().main_job + if args[1] == 'disableall' then + if args[2] == 'on' then + globaldisable = 1 + warning('All automated macro switching disabled.') + elseif args[2] == 'off' then + globaldisable = 0 + notice('Automated macro switching enabled.') + end + elseif args[1]:lower() == 'help' then + log('MacroChanger Commands:') + log('disableall [on|off]') + log(' on - Disables all automated macro switching') + log(' off - Enables all automated macro switching not disabled individually') + log('Resets to what is stored in settings upon unloading of addon. To Permanently change, please change the option in the settings file.') + end end) From 4a0a24112ffc57fca7034808d0e58c3f59aaea5b Mon Sep 17 00:00:00 2001 From: dtw <362017+dtw@users.noreply.github.com> Date: Sat, 13 Feb 2021 16:56:29 +0000 Subject: [PATCH 4/6] Switch warning to notice --- addons/macrochanger/macrochanger.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/macrochanger/macrochanger.lua b/addons/macrochanger/macrochanger.lua index 232ed0967..784b54ba7 100644 --- a/addons/macrochanger/macrochanger.lua +++ b/addons/macrochanger/macrochanger.lua @@ -152,7 +152,7 @@ windower.register_event('addon command', function(...) if args[1] == 'disableall' then if args[2] == 'on' then globaldisable = 1 - warning('All automated macro switching disabled.') + notice('All automated macro switching disabled.') elseif args[2] == 'off' then globaldisable = 0 notice('Automated macro switching enabled.') From 24f3fb0f3561304d3cd0fc6d14393487e7825884 Mon Sep 17 00:00:00 2001 From: dtw <362017+dtw@users.noreply.github.com> Date: Sat, 13 Feb 2021 16:57:01 +0000 Subject: [PATCH 5/6] Use coroutine.sleep --- addons/macrochanger/macrochanger.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/macrochanger/macrochanger.lua b/addons/macrochanger/macrochanger.lua index 784b54ba7..e53512132 100644 --- a/addons/macrochanger/macrochanger.lua +++ b/addons/macrochanger/macrochanger.lua @@ -139,7 +139,9 @@ windower.register_event('job change',function () notice('Auto Macro Switching Disabled for ' .. job ..'.') else log('Job changed to ' .. job .. ' - switched to Book: ' .. book .. ' and Page: ' .. page) - windower.send_command('input /macro book '..book..';wait 0.2;input /macro set '..page..';') + windower.chat.input('/macro book ' .. book) + coroutine.sleep(0.2) + windower.chat.input('/macro set ' .. page) end elseif globaldisable == 1 then notice('Auto Macro Switching Disabled for All Jobs.') From 3b2700ca4198b1986047b2f046366b7f123c3e86 Mon Sep 17 00:00:00 2001 From: dtw <362017+dtw@users.noreply.github.com> Date: Sat, 13 Feb 2021 17:19:32 +0000 Subject: [PATCH 6/6] Whitespace Moar! --- addons/macrochanger/macrochanger.lua | 235 +++++++++++++-------------- 1 file changed, 117 insertions(+), 118 deletions(-) diff --git a/addons/macrochanger/macrochanger.lua b/addons/macrochanger/macrochanger.lua index e53512132..592de141e 100644 --- a/addons/macrochanger/macrochanger.lua +++ b/addons/macrochanger/macrochanger.lua @@ -33,137 +33,136 @@ require('strings') require('logger') windower.register_event('load', function() - globaldisable = 0 - macros = { - WAR = {Book = '', Page = ''}, - MNK = {Book = '', Page = ''}, - WHM = {Book = '', Page = ''}, - BLM = {Book = '', Page = ''}, - RDM = {Book = '', Page = ''}, - THF = {Book = '', Page = ''}, - PLD = {Book = '', Page = ''}, - DRK = {Book = '', Page = ''}, - BST = {Book = '', Page = ''}, - BRD = {Book = '', Page = ''}, - RNG = {Book = '', Page = ''}, - SAM = {Book = '', Page = ''}, - NIN = {Book = '', Page = ''}, - DRG = {Book = '', Page = ''}, - SMN = {Book = '', Page = ''}, - BLU = {Book = '', Page = ''}, - COR = {Book = '', Page = ''}, - PUP = {Book = '', Page = ''}, - DNC = {Book = '', Page = ''}, - SCH = {Book = '', Page = ''}, - GEO = {Book = '', Page = ''}, - RUN = {Book = '', Page = ''}, - } - options_load() + globaldisable = 0 + macros = { + WAR = {Book = '', Page = ''}, + MNK = {Book = '', Page = ''}, + WHM = {Book = '', Page = ''}, + BLM = {Book = '', Page = ''}, + RDM = {Book = '', Page = ''}, + THF = {Book = '', Page = ''}, + PLD = {Book = '', Page = ''}, + DRK = {Book = '', Page = ''}, + BST = {Book = '', Page = ''}, + BRD = {Book = '', Page = ''}, + RNG = {Book = '', Page = ''}, + SAM = {Book = '', Page = ''}, + NIN = {Book = '', Page = ''}, + DRG = {Book = '', Page = ''}, + SMN = {Book = '', Page = ''}, + BLU = {Book = '', Page = ''}, + COR = {Book = '', Page = ''}, + PUP = {Book = '', Page = ''}, + DNC = {Book = '', Page = ''}, + SCH = {Book = '', Page = ''}, + GEO = {Book = '', Page = ''}, + RUN = {Book = '', Page = ''}, + } + options_load() end) function options_load() - local f = io.open(windower.addon_path..'data/settings.txt', "r") - if f == nil then - local g = io.open(windower.addon_path..'data/settings.txt', "w") - g:write('Release Date: 9:00 PM, 4-01-13\46\n') - g:write('Author Comment: This document is whitespace sensitive, which means that you need the same number of spaces between things as exist in this initial settings file\46\n') - g:write('Author Comment: It looks at the first two words separated by spaces and then takes anything as the value in question if the first two words are relevant\46\n') - g:write('Author Comment: If you ever mess it up so that it does not work, you can just delete it and MacroChanger will regenerate it upon reload\46\n') - g:write('Author Comment: For the output customization lines, simply place the book and page number that you would like to change to upon a job change.\46\n') - g:write('Author Comment: If 2 jobs share a book, you can place the same book number for each job, then put their individual pages.\46\n') - g:write('Author Comment: Example: BLM and SCH both use Macro Book 2: BLM uses page 3. SCH uses page 1.\46\n') - g:write('Author Comment: Put BLM Book: 2, BLM Page: 3, SCH Book: 2, SCH Page: 1.\46\n') - g:write('Author Comment: If you wish to disable auto-macro Changing for a specific job, type "disabled" instead of a book number. (e.g. BLM Book: disabled)\n') - g:write('Author Comment: The design of the settings file is credited to Byrthnoth as well as the creation of the settings file.\n\n\n') - g:write('File Settings: Fill in below\n') - g:write('Disable All: 0\n') - g:write('WAR Book: 1\nWAR Page: 1\nMNK Book: 2\nMNK Page: 1\nWHM Book: 3\nWHM Page: 1\nBLM Book: 4\nBLM Page: 1\nRDM Book: 5\nRDM Page: 1\nTHF Book: 6\nTHF Page: 1\n') - g:write('PLD Book: 7\nPLD Page: 1\nDRK Book: 8\nDRK Page: 1\nBST Book: 9\nBST Page: 1\nBRD Book: 10\nBRD Page: 1\nRNG Book: 11\nRNG Page: 1\nSAM Book: 12\nSAM Page: 1\n') - g:write('NIN Book: 13\nNIN Page: 1\nDRG Book: 14\nDRG Page: 1\nSMN Book: 15\nSMN Page: 1\nBLU Book: 16\nBLU Page: 1\nCOR Book: 17\nCOR Page: 1\nPUP Book: 18\nPUP Page: 1\n') - g:write('DNC Book: 19\nDNC Page: 1\nSCH Book: 20\nSCH Page: 1\nGEO Book: 20\nGEO Page: 1\nRUN Book: 20\nRUN Page: 1\n') - g:close() - DisableAll = 0 - macros = { - WAR = {Book = '1', Page = '1'}, - MNK = {Book = '2', Page = '1'}, - WHM = {Book = '3', Page = '1'}, - BLM = {Book = '4', Page = '1'}, - RDM = {Book = '5', Page = '1'}, - THF = {Book = '6', Page = '1'}, - PLD = {Book = '7', Page = '1'}, - DRK = {Book = '8', Page = '1'}, - BST = {Book = '9', Page = '1'}, - BRD = {Book = '10', Page = '1'}, - RNG = {Book = '11', Page = '1'}, - SAM = {Book = '12', Page = '1'}, - NIN = {Book = '13', Page = '1'}, - DRG = {Book = '14', Page = '1'}, - SMN = {Book = '15', Page = '1'}, - BLU = {Book = '16', Page = '1'}, - COR = {Book = '17', Page = '1'}, - PUP = {Book = '18', Page = '1'}, - DNC = {Book = '19', Page = '1'}, - SCH = {Book = '20', Page = '1'}, - GEO = {Book = '20', Page = '1'}, - RUN = {Book = '20', Page = '1'}, - } - print('Default settings file created') - notice('MacroChanger created a settings file and loaded!') - else - f:close() - for curline in io.lines(windower.addon_path..'data/settings.txt') do - local splat = curline:gsub(':',''):split(' ') - local cmd = '' - if splat[1] and macros[splat[1]:upper()] and splat[2] ~=nil and (splat[2]:lower() == 'book' or splat[2]:lower() == 'page') and splat[3] then - macros[splat[1]:upper()][splat[2]:ucfirst()] = splat[3] -- Instead of a number, this can also be 'disabled' - elseif splat[1] and splat[2] and (splat[1]..' '..splat[2]) == 'disable all' and tonumber(splat[3]) then - globaldisable = tonumber(splat[3]) - end + local f = io.open(windower.addon_path..'data/settings.txt', "r") + if f == nil then + local g = io.open(windower.addon_path..'data/settings.txt', "w") + g:write('Release Date: 9:00 PM, 4-01-13\46\n') + g:write('Author Comment: This document is whitespace sensitive, which means that you need the same number of spaces between things as exist in this initial settings file\46\n') + g:write('Author Comment: It looks at the first two words separated by spaces and then takes anything as the value in question if the first two words are relevant\46\n') + g:write('Author Comment: If you ever mess it up so that it does not work, you can just delete it and MacroChanger will regenerate it upon reload\46\n') + g:write('Author Comment: For the output customization lines, simply place the book and page number that you would like to change to upon a job change.\46\n') + g:write('Author Comment: If 2 jobs share a book, you can place the same book number for each job, then put their individual pages.\46\n') + g:write('Author Comment: Example: BLM and SCH both use Macro Book 2: BLM uses page 3. SCH uses page 1.\46\n') + g:write('Author Comment: Put BLM Book: 2, BLM Page: 3, SCH Book: 2, SCH Page: 1.\46\n') + g:write('Author Comment: If you wish to disable auto-macro Changing for a specific job, type "disabled" instead of a book number. (e.g. BLM Book: disabled)\n') + g:write('Author Comment: The design of the settings file is credited to Byrthnoth as well as the creation of the settings file.\n\n\n') + g:write('File Settings: Fill in below\n') + g:write('Disable All: 0\n') + g:write('WAR Book: 1\nWAR Page: 1\nMNK Book: 2\nMNK Page: 1\nWHM Book: 3\nWHM Page: 1\nBLM Book: 4\nBLM Page: 1\nRDM Book: 5\nRDM Page: 1\nTHF Book: 6\nTHF Page: 1\n') + g:write('PLD Book: 7\nPLD Page: 1\nDRK Book: 8\nDRK Page: 1\nBST Book: 9\nBST Page: 1\nBRD Book: 10\nBRD Page: 1\nRNG Book: 11\nRNG Page: 1\nSAM Book: 12\nSAM Page: 1\n') + g:write('NIN Book: 13\nNIN Page: 1\nDRG Book: 14\nDRG Page: 1\nSMN Book: 15\nSMN Page: 1\nBLU Book: 16\nBLU Page: 1\nCOR Book: 17\nCOR Page: 1\nPUP Book: 18\nPUP Page: 1\n') + g:write('DNC Book: 19\nDNC Page: 1\nSCH Book: 20\nSCH Page: 1\nGEO Book: 20\nGEO Page: 1\nRUN Book: 20\nRUN Page: 1\n') + g:close() + DisableAll = 0 + macros = { + WAR = {Book = '1', Page = '1'}, + MNK = {Book = '2', Page = '1'}, + WHM = {Book = '3', Page = '1'}, + BLM = {Book = '4', Page = '1'}, + RDM = {Book = '5', Page = '1'}, + THF = {Book = '6', Page = '1'}, + PLD = {Book = '7', Page = '1'}, + DRK = {Book = '8', Page = '1'}, + BST = {Book = '9', Page = '1'}, + BRD = {Book = '10', Page = '1'}, + RNG = {Book = '11', Page = '1'}, + SAM = {Book = '12', Page = '1'}, + NIN = {Book = '13', Page = '1'}, + DRG = {Book = '14', Page = '1'}, + SMN = {Book = '15', Page = '1'}, + BLU = {Book = '16', Page = '1'}, + COR = {Book = '17', Page = '1'}, + PUP = {Book = '18', Page = '1'}, + DNC = {Book = '19', Page = '1'}, + SCH = {Book = '20', Page = '1'}, + GEO = {Book = '20', Page = '1'}, + RUN = {Book = '20', Page = '1'}, + } + print('Default settings file created') + notice('MacroChanger created a settings file and loaded!') + else + f:close() + for curline in io.lines(windower.addon_path..'data/settings.txt') do + local splat = curline:gsub(':',''):split(' ') + local cmd = '' + if splat[1] and macros[splat[1]:upper()] and splat[2] ~=nil and (splat[2]:lower() == 'book' or splat[2]:lower() == 'page') and splat[3] then + macros[splat[1]:upper()][splat[2]:ucfirst()] = splat[3] -- Instead of a number, this can also be 'disabled' + elseif splat[1] and splat[2] and (splat[1]..' '..splat[2]) == 'disable all' and tonumber(splat[3]) then + globaldisable = tonumber(splat[3]) + end + end + notice('MacroChanger read from a settings file and loaded!') end - notice('MacroChanger read from a settings file and loaded!') - end end windower.register_event('job change',function () -- Could use the job ID passed into this function, but the addon would have to include the resources library - local job = windower.ffxi.get_player().main_job - local book = '' - local page = '' - if globaldisable == 0 then + local job = windower.ffxi.get_player().main_job + local book = '' + local page = '' + if globaldisable == 0 then if job and macros[job] then - book = macros[job].Book - page = macros[job].Page - end - - if ((book == 'disabled') or (page == 'disabled')) then - notice('Auto Macro Switching Disabled for ' .. job ..'.') - else - log('Job changed to ' .. job .. ' - switched to Book: ' .. book .. ' and Page: ' .. page) - windower.chat.input('/macro book ' .. book) - coroutine.sleep(0.2) - windower.chat.input('/macro set ' .. page) + book = macros[job].Book + page = macros[job].Page + end + if ((book == 'disabled') or (page == 'disabled')) then + notice('Auto Macro Switching Disabled for ' .. job ..'.') + else + log('Job changed to ' .. job .. ' - switched to Book: ' .. book .. ' and Page: ' .. page) + windower.chat.input('/macro book ' .. book) + coroutine.sleep(0.2) + windower.chat.input('/macro set ' .. page) + end + elseif globaldisable == 1 then + notice('Auto Macro Switching Disabled for All Jobs.') end - elseif globaldisable == 1 then - notice('Auto Macro Switching Disabled for All Jobs.') - end end) windower.register_event('addon command', function(...) local args = {...} - local mjob = windower.ffxi.get_player().main_job - if args[1] == 'disableall' then - if args[2] == 'on' then - globaldisable = 1 - notice('All automated macro switching disabled.') - elseif args[2] == 'off' then - globaldisable = 0 - notice('Automated macro switching enabled.') + local mjob = windower.ffxi.get_player().main_job + if args[1] == 'disableall' then + if args[2] == 'on' then + globaldisable = 1 + notice('All automated macro switching disabled.') + elseif args[2] == 'off' then + globaldisable = 0 + notice('Automated macro switching enabled.') + end + elseif args[1]:lower() == 'help' then + log('MacroChanger Commands:') + log('disableall [on|off]') + log(' on - Disables all automated macro switching') + log(' off - Enables all automated macro switching not disabled individually') + log('Resets to what is stored in settings upon unloading of addon. To Permanently change, please change the option in the settings file.') end - elseif args[1]:lower() == 'help' then - log('MacroChanger Commands:') - log('disableall [on|off]') - log(' on - Disables all automated macro switching') - log(' off - Enables all automated macro switching not disabled individually') - log('Resets to what is stored in settings upon unloading of addon. To Permanently change, please change the option in the settings file.') - end end)