Skip to content

Commit

Permalink
Add welcome message to inform user of slash commands.
Browse files Browse the repository at this point in the history
Added a toggle to turn it off and on.
  • Loading branch information
Kkthnx committed Jan 5, 2025
1 parent 148fc5b commit 81787b4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
11 changes: 11 additions & 0 deletions LevelUpFX/Config/Settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -111,3 +118,7 @@ end)
namespace:RegisterOptionCallback("chatEmoteOnLevelUp", function(value)
namespace.chatEmoteEnabled = value
end)

namespace:RegisterOptionCallback("welcomeMessage", function(value)
namespace.showWelcomeMessage = value
end)
30 changes: 17 additions & 13 deletions LevelUpFX/LevelUpFX.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down

0 comments on commit 81787b4

Please sign in to comment.