From 2af4bc8a7e3eadeee091289131e05493a87da5ab Mon Sep 17 00:00:00 2001 From: Ebbe Date: Sat, 26 Apr 2025 19:26:12 +0200 Subject: [PATCH] fixed lugin Signed-off-by: Ebbe --- custom notifications.lua | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/custom notifications.lua b/custom notifications.lua index 5d1636f..c3d5f97 100644 --- a/custom notifications.lua +++ b/custom notifications.lua @@ -1,26 +1,40 @@ debug = true -function debug_print(message) +local function debug_print(message) if debug == true then Printf(tostring(message)) end end -function main(display_handle, args) + +local function split_first(inputstr, sep) + local sep = sep or ";" + local sep_pos = string.find(inputstr, sep) + if not sep_pos then + return inputstr, nil + end + local first = string.sub(inputstr, 1, sep_pos - 1) + local rest = string.sub(inputstr, sep_pos + 1) + return first, rest +end + +local function main(display_handle, args) if args then timeout = 5 - timeout, seperator, message = args.partition(";") + local timeoutStr, message = split_first(args, ";") + timeout = tonumber(timeoutStr) or timeout + local messageTable = { title = "Notification!", message = tostring(message), - timeout = tonumber(timeout*1000), + timeout = timeout * 1000, -- convert seconds to milliseconds timeoutResultCancel = false, timeoutResultID = 99, } local returnTable = MessageBox(messageTable) else - Printf('You must atleast specify your notification message. You can do this by running the following command: Plugin "custom notifications" "5;Hello this is a notification!"\nThis will create a message with a duration of 5 seconds.') + Printf('You must at least specify your notification message. Example:\nPlugin "custom notifications" "5;Hello this is a notification!"\nThis will create a message with a duration of 5 seconds.') end end