Skip to content

Commit

Permalink
✨ Added colorized MOTD text when loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
AssisrMatheus committed Sep 15, 2019
1 parent cb7954d commit c907c47
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 5 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
# TodoChecklister
I have bad memory so I made this. A todolist/checklist AddOn for World of Warcraft

![demoGif](./demo.gif)

**I have tested it only in WoW Classic**

## Reference material

- [A Guide and Reference for Creating WoW Addons: WoW Programming](http://garde.sylvanas.free.fr/ressources/Guides/Macros-Addons/Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons.pdf)
Expand Down
6 changes: 3 additions & 3 deletions constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ local Constants = core.Constants;
Constants.debugMode = true;
Constants.addonName = addonName;
Constants.theme = {
red = 0,
green = 0.8, -- 204/255
red = 0.8, -- 204/255
green = 0.2, -- 51/255
blue = 1,
hex = "00ccff"
hex = "cc33ff"
};
Binary file added demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 35 additions & 2 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,41 @@ function core:Init(event, name)

core.Debug:Init();
core.Chat:Init();

core.Chat:Print("All loaded :)");

if (#TodoChecklisterDB > 0) then
local completedList = core.TableUtils:Filter(TodoChecklisterDB, function(x) return x.isChecked == true end)
local notList = core.TableUtils:Filter(TodoChecklisterDB, function(x) return x.isChecked == false end)

if (#completedList > 0 and #notList > 0) then
local completedTaskPlural = ""
if (#completedList > 1) then
completedTaskPlural = "tasks"
else
completedTaskPlural = "task"
end

local notTaskPlural = ""
if (#notList > 1) then
notTaskPlural = "tasks"
else
notTaskPlural = "task"
end

core.Chat:Print("You have |cff6cf900"..tostring(#completedList).."|r completed "..completedTaskPlural.." and |cffff0000"..tostring(#notList).."|r pending "..notTaskPlural);
elseif (#completedList > 0) then
core.Chat:Print("You have completed all your tasks");
elseif (#notList > 0) then
local taskPlural = ""
if (#notList > 1) then
taskPlural = "tasks"
else
taskPlural = "task"
end
core.Chat:Print("You have |cffff0000"..tostring(#notList).."|r pending "..taskPlural);
end
else
core.Chat:Print("You have no pending tasks.");
end
end

local events = CreateFrame("Frame");
Expand Down
8 changes: 8 additions & 0 deletions tableUtils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@ function TableUtils:IndexOf(tb, comparator)
for i=1, #tb do
if(comparator(tb[i])) then return i end
end
end

function TableUtils:Filter(tb, comparator)
local newTb = {};
for i=1, #tb do
if(comparator(tb[i])) then table.insert(newTb, #newTb+1, tb[i]) end
end
return newTb
end

0 comments on commit c907c47

Please sign in to comment.