diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-06-11 22:05:00 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-06-11 22:05:00 -0400 |
commit | f95dc89d5e7481f4e02953617ce7a13feb87d27a (patch) | |
tree | 25cf983b52a3017071964a4105b87414626d4ff7 /indra/newview/scripts/lua | |
parent | beb28c4351f3ef622c45f3603df0ba9c5e162793 (diff) |
Add popup.lua, a preliminary API for viewer notifications.
WIP: This is known not to work yet.
Diffstat (limited to 'indra/newview/scripts/lua')
-rw-r--r-- | indra/newview/scripts/lua/popup.lua | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/indra/newview/scripts/lua/popup.lua b/indra/newview/scripts/lua/popup.lua new file mode 100644 index 0000000000..65b04b513e --- /dev/null +++ b/indra/newview/scripts/lua/popup.lua @@ -0,0 +1,32 @@ +leap = require 'leap' + +-- notification is any name defined in notifications.xml as +-- <notification name=> +-- vars is a table providing values for [VAR] substitution keys in the +-- notification body. +local popup_meta = { + -- setting this function as getmetatable(popup).__call() means this gets + -- called when a consumer calls popup(notification, vars, payload) + __call = function(self, notification, vars, payload) + return leap.request('LLNotifications', + {op='requestAdd', name=notification, + substitutions=vars, + payload=payload or {}}) + end +} + +local popup = setmetatable({}, popup_meta) + +function popup:alert(message) + return self('GenericAlert', {MESSAGE=message}) +end + +function popup:alertOK(message) + return self('GenericAlertOK', {MESSAGE=message}) +end + +function popup:alertYesCancel(message) + return self('GenericAlertYesCancel', {MESSAGE=message}) +end + +return popup |