- CASE insensitive matching

github@spradlin.dev [09-19-21 - 02:36]
- CASE insensitive matching
- "Add Current Zone" button based of last zone entered.
Filename
MuteBards2.lua
MuteBards2.txt
MuteBardsOptions.lua
diff --git a/MuteBards2.lua b/MuteBards2.lua
index 04ab99c..4fcda1c 100644
--- a/MuteBards2.lua
+++ b/MuteBards2.lua
@@ -1,6 +1,6 @@
 MuteBards = MuteBards or {};
 MuteBards.name = "MuteBards2"
-MuteBards.Version = "2.03"
+MuteBards.Version = "2.0 r5"

 local savedVars = {}
 MuteBards.sv = savedVars; -- saved vars
@@ -71,7 +71,7 @@ end
 function MuteBards:RemoveZone(zoneName, cb)
   if (MuteBards:ContainsZone(zoneName)) then
     for i, v in ipairs(getSVZones(savedVars)) do
-      if (v == zoneName) then
+      if (v:lower() == zoneName:lower()) then
         table.remove(getSVZones(savedVars), i);
         d('Zone ' .. zoneName .. ' removed from list');
         if (cb ~= nil) then
@@ -89,7 +89,7 @@ function MuteBards:ContainsZone(zoneName)
     return false;
   end
   for i, v in ipairs(getSVZones(savedVars)) do
-    if (v == zoneName) then
+    if (v:lower() == zoneName:lower()) then
       return true;
     end
   end
diff --git a/MuteBards2.txt b/MuteBards2.txt
index 0354152..4612896 100644
--- a/MuteBards2.txt
+++ b/MuteBards2.txt
@@ -1,7 +1,7 @@
 ## Title: MuteBards 2
 ## Description: Mute Bards given subzones (like cities).  Type /mutebards to open the settings, where you can add or remove zones.  Make sure to click the refresh button when you're done to allow the changes to take effect.
 ## APIVersion: 101031
-## Version: 2.0 r3
+## Version: 2.0 r5
 ## AddOnVersion: 1
 ## SavedVariables: MuteBards_Settings
 ## DependsOn: LibAddonMenu-2.0>=31
diff --git a/MuteBardsOptions.lua b/MuteBardsOptions.lua
index 7eb3f70..cf7415c 100644
--- a/MuteBardsOptions.lua
+++ b/MuteBardsOptions.lua
@@ -27,25 +27,36 @@ function MuteBards:InitSettingsPanel(svZones, svChar)
   local zoneToAdd, zoneToRemove

   local optionsTable = {
-    [1] = {
+    {
       type = "header",
       name = "Zones",
       width = "full", --or "half" (optional)
     },
-    [2] = {
+    {
       type = "description",
       --title = "My Title",	--(optional)
       text = "Add the exact subzone (usually town) name for the zone you wish to mute bards in.  For example, \"Solitude\" or \"Rimmen\" (without quotes)",
       width = "full", --or "half" (optional)
     },
-    [3] = {
+    {
       type = "description",
       title = "Current Zone:",	--(optional)
       text = function() return "  " .. getCurrentZoneName(svChar) end,

-      width = "full", --or "half" (optional)
+      width = "half", --or "half" (optional)
+    },
+    {
+      type = "button",
+      name = "Add Current Zone",
+      disabled = function()  return getCurrentZoneName(svChar) == "UNKNOWN" end,
+      func = function()
+        if (getCurrentZoneName(svChar) ~= "UNKNOWN") then
+          MuteBards:AddZone(getCurrentZoneName(svChar), refreshCallback);
+        end
+      end,
+      width = "half", --or "half" (optional)
     },
-    [4] = {
+    {
       type = "editbox",
       name = "Add Zone:",
       tooltip = "Zone Name",
@@ -59,7 +70,7 @@ function MuteBards:InitSettingsPanel(svZones, svChar)
       width = "half", --or "half" (optional)
       default = "", --(optional)
     },
-    [5] = {
+    {
       type = "button",
       name = "Add",
       func = function()
@@ -68,7 +79,7 @@ function MuteBards:InitSettingsPanel(svZones, svChar)
       end,
       width = "half", --or "half" (optional)
     },
-    [6] = {
+    {
       type = "description",
       title = "Currently Muted Zones:",
       text = function()
@@ -77,7 +88,7 @@ function MuteBards:InitSettingsPanel(svZones, svChar)
       width = "full",
       requiresReload = true,
     },
-    [7] = {
+    {
       type = "editbox",
       name = "Remove Zone:",
       getFunc = function()
@@ -90,7 +101,7 @@ function MuteBards:InitSettingsPanel(svZones, svChar)
       width = "half", --or "full" (optional)
       default = "", --(optional)
     },
-    [8] = {
+    {
       type = "button",
       name = "Remove",
       func = function()
@@ -99,7 +110,7 @@ function MuteBards:InitSettingsPanel(svZones, svChar)
       end,
       width = "half", --or "full" (optional)
     },
-    [9] = {
+    {
       type = "button",
       name = "Force Refresh",
       func = refreshCallback,