From a12844272812f5b315254398a45bd97f39b89b9d Mon Sep 17 00:00:00 2001 From: Conrado Sampaio <102433904+sampconrad@users.noreply.github.com> Date: Mon, 9 Sep 2024 13:57:18 -0300 Subject: [PATCH] Feat: modified custom code block to now accept a function --- CombatMode/CombatMode.toc | 2 +- CombatMode/Config.lua | 20 +++++++++----------- CombatMode/Constants.lua | 4 ++-- CombatMode/Core.lua | 10 +++++----- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/CombatMode/CombatMode.toc b/CombatMode/CombatMode.toc index b02dc29..fb3cb4d 100644 --- a/CombatMode/CombatMode.toc +++ b/CombatMode/CombatMode.toc @@ -1,5 +1,5 @@ ## Interface: 110002 -## Version: 2.4.6 +## Version: 2.4.7 ## Title: |A:::|a|TInterface\Addons\CombatMode\assets\cmtitle:22:95|t ## Author: justice7ca, sampconrad. diff --git a/CombatMode/Config.lua b/CombatMode/Config.lua index bc6e35d..684baaa 100644 --- a/CombatMode/Config.lua +++ b/CombatMode/Config.lua @@ -96,7 +96,7 @@ local function Description(option, order) }, advanced = { type = "description", - name = "\nCreate your own conditions that force a |cff00FF7FCursor Unlock|r by entering a chunk of Lua code that returns |cff00FF7FTrue|r if the cursor should be freed, |cffE52B50False|r otherwise.\n|cff909090E.g.: to unlock the cursor while standing still or riding a mount, enter: |cff69ccf0GetUnitSpeed(\"player\") == 0 or IsMounted()|r\n\n", + name = "\nCreate your own conditions that force a |cff00FF7FCursor Unlock|r by writing a function that returns |cff00FF7FTrue|r if the cursor should be unlocked, |cffE52B50False|r otherwise.\n\n", fontSize = "medium", order = order } @@ -112,15 +112,15 @@ local function GetButtonOverrideGroup(modifier, groupOrder) local capitalisedModifier = (string.upper(modifier)) groupName = capitalisedModifier .. " + Clicks" - button1Name = capitalisedModifier .. " + Left Click Action" - button2Name = capitalisedModifier .. " + Right Click Action" + button1Name = "|cffB47EDE" .. capitalisedModifier .. " + Left Click Action" .. "|r" + button2Name = "|cffB47EDE" .. capitalisedModifier .. " + Right Click Action" .. "|r" else button1Settings = "button1" button2Settings = "button2" groupName = "Base Clicks" - button1Name = "Left Click Action" - button2Name = "Right Click Action" + button1Name = "|cffB47EDE" .. "Left Click Action" .. "|r" + button2Name = "|cffB47EDE" .. "Right Click Action" .. "|r" end return { @@ -131,8 +131,7 @@ local function GetButtonOverrideGroup(modifier, groupOrder) overrideButton1Toggle = { type = "toggle", name = "|A:NPE_LeftClick:38:38|a", - desc = "Enables the use of the |cffB47EDE" .. button1Name .. - "|r casting override while in |cffE52B50Mouse Look|r mode.", + desc = "Enables the use of the " .. button1Name .. " casting override while in |cffE52B50Mouse Look|r mode.", width = 0.4, order = 1, set = function(_, value) @@ -202,8 +201,7 @@ local function GetButtonOverrideGroup(modifier, groupOrder) overrideButton2Toggle = { type = "toggle", name = "|A:NPE_RightClick:38:38|a", - desc = "Enable the use of the |cffB47EDE" .. button2Name .. - "|r casting override while in |cffE52B50Mouse Look|r mode.", + desc = "Enable the use of the " .. button2Name .. " casting override while in |cffE52B50Mouse Look|r mode.", width = 0.4, order = 2, set = function(_, value) @@ -977,7 +975,7 @@ local AdvancedConfigOptions = { type = "input", name = "Custom Condition:", order = 1, - multiline = 6, + multiline = 16, width = "full", set = function(_, input) CM.DB.global.customCondition = input @@ -999,7 +997,7 @@ local AdvancedConfigOptions = { order = 1 }, wowpediaApi = { - name = "You can find all available functions and how to use them here:", + name = "You can find the documentation for the WoW API here:", desc = "warcraft.wiki.gg/wiki/World_of_Warcraft_API", type = "input", width = 2.2, diff --git a/CombatMode/Constants.lua b/CombatMode/Constants.lua index 6de982c..5c16aaf 100644 --- a/CombatMode/Constants.lua +++ b/CombatMode/Constants.lua @@ -550,8 +550,8 @@ CM.Constants.ActionsToProcess = { -- Matches the bindable actions values defined right above with more readable names for the UI CM.Constants.OverrideActions = { - CLEARFOCUS = "Clear Focus", - CLEARTARGET = "Clear Target", + CLEARFOCUS = "|cff69ccf0Clear Focus|r", + CLEARTARGET = "|cff69ccf0Clear Target|r", MACRO = "|cff69ccf0Run MACRO|r" } diff --git a/CombatMode/Core.lua b/CombatMode/Core.lua index 35deabd..68265ad 100644 --- a/CombatMode/Core.lua +++ b/CombatMode/Core.lua @@ -523,13 +523,13 @@ local function IsCustomConditionTrue() return false end - local customConditionFunction, error = loadstring("return " .. CM.DB.global.customCondition) - if not customConditionFunction then - CM.DebugPrint(error) + local func, err = loadstring(CM.DB.global.customCondition) + if not func then + CM.DebugPrint(err) return false - else - return customConditionFunction() end + + return func end local function IsVendorMountOut()