Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console help command #13

Merged
merged 3 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions classes/db.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ function db:resetLootCouncilData()
LootPlanItDB.lootCouncil = {}
LootPlanItDB.lootCouncil.itemIds = {}
LootPlanItDB.lootCouncil.metaData = {}

LPI:infoMessage("Deleted loot council items!")
end

function LPI:importLootCouncilData(data)
Expand Down
1 change: 0 additions & 1 deletion classes/lootImport.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ function lootImportOverview:draw()
buttonClear:SetCallback("OnClick",
function()
db:resetLootCouncilData()
LPI:infoMessage("Deleted Loot Council Items!")
AceGUI:Release(window)
lootImportOverview:draw()
end);
Expand Down
50 changes: 42 additions & 8 deletions classes/slashCommands.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,47 @@
local _, LPI = ...;

LPI.Ace:RegisterChatCommand("lpi", "SlashCommand");
LPI.Ace:RegisterChatCommand("lpi", "runSlashCommand");

function LPI.Ace:SlashCommand(msg)
if msg == "reset" then
db:resetLootCouncilData()
elseif msg == "v" then
LPI:infoMessage(LPI.name .. " v" .. LPI.version)
LPI.slashCommands = {
["commands"] = {
help = function() LPI:printHelp(); end,
version = function() LPI:printAddonVersion(); end,
reset = function() db:resetLootCouncilData(); end,
import = function() lootImportOverview:draw(); end,
},
["commandsShort"] = {
h = "help",
v = "version",
r = "reset",
i = "import",
},
}

function LPI.Ace:runSlashCommand(...)
local command = ...

if command == "" then
LPI:printHelp()
else
lootImportOverview:draw()
if LPI.slashCommands.commands[command] then
LPI.slashCommands.commands[command]()
elseif LPI.slashCommands.commandsShort[command] then
local commandLongified = LPI.slashCommands.commandsShort[command]

LPI.slashCommands.commands[commandLongified]()
else
print("|cffff0000Unknown command|r: " .. command .. ". Type |cff0088ff/lpi help|r if you need any help")
end
end
end
end

function LPI:printHelp()
LPI:infoMessage("/lpi help or /lpi h to show this menu")
LPI:infoMessage("/lpi import or /lpi i to open import gui")
LPI:infoMessage("/lpi version or /lpi v to print current version to chat")
LPI:infoMessage("/lpi reset or /lpi r to reset database if some update fails or a random bug occurs")
end

function LPI:printAddonVersion()
LPI:infoMessage(LPI.name .. " " .. LPI.version)
end
2 changes: 1 addition & 1 deletion classes/welcomeMessage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local _, LPI = ...;

function LPI.Ace:OnInitialize()
print(string.format(
"|cff0088ff%s v%s|r by %s. Type |cff0088ff/lpi|r to start!",
"|cff0088ff%s %s|r by %s. Type |cff0088ff/lpi|r to start! |cff0088ff/lpi h|r to show help menu.",
LPI.title,
LPI.version,
LPI.author
Expand Down