From 81787b4fc71f77c37bcc954b69e36e80d810320d Mon Sep 17 00:00:00 2001 From: Kkthnx <40672673+Kkthnx@users.noreply.github.com> Date: Sun, 5 Jan 2025 14:15:38 -0500 Subject: [PATCH] Add welcome message to inform user of slash commands. Added a toggle to turn it off and on. --- LevelUpFX/Config/Settings.lua | 11 +++++++++++ LevelUpFX/LevelUpFX.lua | 30 +++++++++++++++++------------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/LevelUpFX/Config/Settings.lua b/LevelUpFX/Config/Settings.lua index be9e97d..9c5da74 100644 --- a/LevelUpFX/Config/Settings.lua +++ b/LevelUpFX/Config/Settings.lua @@ -84,6 +84,13 @@ namespace:RegisterSettings("LevelUpFXDB", { valueStep = 1, valueFormat = "%d", }, + { + key = "welcomeMessage", + type = "toggle", + title = "Show Welcome Message", + tooltip = "Show a welcome message with slash commands on first use.", + default = true, + }, }) namespace:RegisterOptionCallback("enableAddon", function(value) @@ -111,3 +118,7 @@ end) namespace:RegisterOptionCallback("chatEmoteOnLevelUp", function(value) namespace.chatEmoteEnabled = value end) + +namespace:RegisterOptionCallback("welcomeMessage", function(value) + namespace.showWelcomeMessage = value +end) diff --git a/LevelUpFX/LevelUpFX.lua b/LevelUpFX/LevelUpFX.lua index 3cb43a6..6d3bb00 100644 --- a/LevelUpFX/LevelUpFX.lua +++ b/LevelUpFX/LevelUpFX.lua @@ -143,19 +143,16 @@ local function ShowLevelUpMessage(level, statGains, isMoving) end -- Event handler -namespace:RegisterEvent( - "PLAYER_LEVEL_UP", - function(_, level, _, _, _, strengthDelta, agilityDelta, staminaDelta, intellectDelta, spiritDelta) - local statGains = { - Strength = strengthDelta or 0, - Agility = agilityDelta or 0, - Stamina = staminaDelta or 0, - Intellect = intellectDelta or 0, - Spirit = spiritDelta or 0, - } - ShowLevelUpMessage(level, statGains) - end -) +namespace:RegisterEvent("PLAYER_LEVEL_UP", function(_, level, _, _, _, strengthDelta, agilityDelta, staminaDelta, intellectDelta, spiritDelta) + local statGains = { + Strength = strengthDelta or 0, + Agility = agilityDelta or 0, + Stamina = staminaDelta or 0, + Intellect = intellectDelta or 0, + Spirit = spiritDelta or 0, + } + ShowLevelUpMessage(level, statGains) +end) -- Combat event handlers namespace:RegisterEvent("PLAYER_REGEN_DISABLED", function() @@ -177,6 +174,13 @@ namespace:RegisterEvent("PLAYER_REGEN_ENABLED", function() end end) +namespace.OnLoad = function() + if namespace:GetOption("welcomeMessage") then + print("|cff5bc0beLevelUpFX|r loaded. Type |cff00ff00/lu test [level]|r to test the level-up message.") + print("Other commands: |cff00ff00/lu unlock|r to unlock the frame, |cff00ff00/lu lock|r to lock the frame.") + end +end + -- Slash command for testing namespace:RegisterSlash("/lu", function(msg) if msg == "test" then