diff --git a/Modules/Noter.lua b/Modules/Noter.lua index b629086..fd01ca0 100644 --- a/Modules/Noter.lua +++ b/Modules/Noter.lua @@ -42,6 +42,8 @@ function shared.Noter.Init() return ret end + ---@param name string + ---@param args string[] local function DeleteNotes(name, args) if Heimdall_Data.config.noter.debug then print(string.format("[%s] Delete note command received for: %s", ModuleName, name)) @@ -89,6 +91,13 @@ function shared.Noter.Init() end end end + + ---@param note Note + local function PrintNote(note) + print(string.format("[%s] %s: %s", note.source, note.date, note.note)) + end + ---@param name string + ---@param args string[] local function PrintNotes(name, args) if Heimdall_Data.config.noter.debug then print(string.format("[%s] Print note command received for: %s", ModuleName, name)) @@ -131,11 +140,26 @@ function shared.Noter.Init() print(string.format("[%s] Printing note %s at index %s", ModuleName, name, i)) shared.dumpTable(Heimdall_Data.config.notes[name][i]) end + PrintNote(Heimdall_Data.config.notes[name][i]) end end end end + ---@param name string + ---@param sender string + ---@param args string[] + local function AddNote(name, sender, args) + if not Heimdall_Data.config.notes[name] then Heimdall_Data.config.notes[name] = {} end + shared.dumpTable(args) + local note = { + source = sender, + date = date(), + note = args[3] + } + table.insert(Heimdall_Data.config.notes[name], note) + end + -- Here's the plan: -- Implement a "note" command, that will do everything -- Saying "note " will add a note to the list for the character @@ -196,8 +220,11 @@ function shared.Noter.Init() local note = strtrim(args[3]) if note == "delete" then DeleteNotes(name, args) + -- Incorrect... We do not NEED a range for print, we also print last N if we say "note ", fix this elseif string.find(note, "%d") then PrintNotes(name, args) + else + AddNote(name, sender, args) end end end)