Skip to content

Commit

Permalink
Merge pull request #136 from djsmithdev/development
Browse files Browse the repository at this point in the history
Feat: modified custom code block to now accept a function
  • Loading branch information
sampconrad authored Sep 9, 2024
2 parents 612178b + a128442 commit 0828048
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion CombatMode/CombatMode.toc
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
20 changes: 9 additions & 11 deletions CombatMode/Config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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 {
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions CombatMode/Constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down
10 changes: 5 additions & 5 deletions CombatMode/Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 0828048

Please sign in to comment.