Skip to content

Commit

Permalink
Add progress param to nofication
Browse files Browse the repository at this point in the history
  • Loading branch information
thegrb93 committed Aug 11, 2024
1 parent 84e445a commit 0f1c007
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lua/starfall/libs_cl/notification.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,19 @@ end
--- Displays a notification with an animated progress bar, will persist unless killed or chip is removed.
-- @param string id String index of the notification
-- @param string text The text to display
function notification_library.addProgress(id, text)
-- @param number? progress An optional progress val 0-1 indicating progress.
function notification_library.addProgress(id, text, progress)
if SF.IsHUDActive(instance.entity) then
checkpermission(instance, nil, "notification.hud")
else
checkpermission(instance, nil, "notification")
end
checkluatype(id, TYPE_STRING)
checkluatype(text, TYPE_STRING)
if progress~=nil then
checkluatype(text, TYPE_NUMBER)
progress = math.Clamp(progress, 0, 1)
end

if #id > 256 then SF.Throw("ID is greater than 256 limit!", 2) end
if #text > 256 then SF.Throw("Text is greater than 256 limit!", 2) end
Expand All @@ -72,7 +77,7 @@ function notification_library.addProgress(id, text)
SF.Throw("Invalid chip owner", 2)
end

notification.AddProgress( id, text )
notification.AddProgress( id, text, progress )
notifications[id] = true
end

Expand Down

0 comments on commit 0f1c007

Please sign in to comment.