From e68b930fac4906301aaf112136d14ac36ca6ceab Mon Sep 17 00:00:00 2001 From: lili-ffxi <40600148+lili-ffxi@users.noreply.github.com> Date: Tue, 25 Jul 2023 15:39:59 +0100 Subject: [PATCH 1/2] Update setbgm.lua Added `find` argument and corresponding functionality to search song names for a provided string. --- addons/setbgm/setbgm.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/addons/setbgm/setbgm.lua b/addons/setbgm/setbgm.lua index 450b746b1..390b2dda6 100644 --- a/addons/setbgm/setbgm.lua +++ b/addons/setbgm/setbgm.lua @@ -31,7 +31,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --]] _addon.name = 'setbgm' -_addon.version = '1.2.3' +_addon.version = '1.3.0' _addon.command = 'setbgm' _addon.author = 'Seth VanHeulen (Acacia@Odin)' @@ -118,6 +118,15 @@ function display_songs() end end +function find_songs(str) + windower.add_to_chat(207, 'Songs matching %s:':format(str:color(204))) + for id=25,900 do + if songs[id] and songs[id]:lower():find(str) then + windower.add_to_chat(207, ' %s: %s':format(tostring(id):color(204), songs[id])) + end + end +end + function display_music_types() windower.add_to_chat(207, 'Available music types:') local output = ' ' @@ -130,6 +139,7 @@ end function display_help() windower.add_to_chat(167, 'Command usage:') windower.add_to_chat(167, ' setbgm list [music|type]') + windower.add_to_chat(167, ' setbgm find ') windower.add_to_chat(167, ' setbgm []') windower.add_to_chat(167, ' setbgm ') end @@ -145,6 +155,10 @@ function setbgm_command(...) elseif #arg == 2 and arg[1]:lower() == 'list' and arg[2]:lower() == 'type' then display_music_types() return + elseif #arg == 2 and arg[1]:lower() == 'find' then + local str = arg[2]:lower() + find_songs(str) + return elseif #arg == 1 then set_music(nil, arg[1]) return From 21df0324635171b7f5d0e437b2a2c04352ebec73 Mon Sep 17 00:00:00 2001 From: lili-ffxi <40600148+lili-ffxi@users.noreply.github.com> Date: Mon, 14 Aug 2023 21:49:38 +0100 Subject: [PATCH 2/2] Update setbgm.lua The `find` argument will print a notice if no matching songs are found. --- addons/setbgm/setbgm.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/addons/setbgm/setbgm.lua b/addons/setbgm/setbgm.lua index 390b2dda6..42d831405 100644 --- a/addons/setbgm/setbgm.lua +++ b/addons/setbgm/setbgm.lua @@ -120,11 +120,17 @@ end function find_songs(str) windower.add_to_chat(207, 'Songs matching %s:':format(str:color(204))) + local output = '' for id=25,900 do if songs[id] and songs[id]:lower():find(str) then - windower.add_to_chat(207, ' %s: %s':format(tostring(id):color(204), songs[id])) + output = output .. '\n %s: %s':format(tostring(id):color(204), songs[id]) end end + if output ~= '' then + windower.add_to_chat(207,output) + else + windower.add_to_chat(207,' No songs matching %s found.':format(str:color(204))) + end end function display_music_types() @@ -155,8 +161,9 @@ function setbgm_command(...) elseif #arg == 2 and arg[1]:lower() == 'list' and arg[2]:lower() == 'type' then display_music_types() return - elseif #arg == 2 and arg[1]:lower() == 'find' then - local str = arg[2]:lower() + elseif #arg > 1 and arg[1]:lower() == 'find' then + table.remove(arg,1) + local str = table.concat(arg,' ') find_songs(str) return elseif #arg == 1 then