gma3-notification-plugin/custom_notify.lua

41 lines
1.2 KiB
Lua

local debug_mode = false
local function debug_print(message)
if debug_mode == true then
Printf(tostring(message))
end
end
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 notification(display_handle, args)
if args then
timeout = 5
local timeoutStr, message = split_first(args, ";")
timeout = tonumber(timeoutStr) or timeout
local messageTable = {
title = "Notification!",
message = tostring(message),
timeout = timeout * 1000,
timeoutResultCancel = false,
timeoutResultID = 99,
}
local returnTable = MessageBox(messageTable)
else
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
return notification