diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-06-20 16:28:47 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-06-20 16:28:47 -0400 |
commit | 22ec77c03d01a973c871ae59fd95a8397bf07fb8 (patch) | |
tree | 530b30d1dde4ea274566489d42cfd07b2f882167 /indra/newview/scripts/lua | |
parent | 09b814a2dc6d3a647d75bcf0a310eba2678a0228 (diff) | |
parent | d7d18aaad0e7b8412e50fd82d446d31611207175 (diff) |
Merge branch 'release/luau-scripting' into lua-chat-listener
Diffstat (limited to 'indra/newview/scripts/lua')
-rw-r--r-- | indra/newview/scripts/lua/LLNotification.lua | 15 | ||||
-rw-r--r-- | indra/newview/scripts/lua/luafloater_speedometer.xml | 35 | ||||
-rw-r--r-- | indra/newview/scripts/lua/test_luafloater_speedometer.lua | 32 |
3 files changed, 82 insertions, 0 deletions
diff --git a/indra/newview/scripts/lua/LLNotification.lua b/indra/newview/scripts/lua/LLNotification.lua new file mode 100644 index 0000000000..f47730d1cc --- /dev/null +++ b/indra/newview/scripts/lua/LLNotification.lua @@ -0,0 +1,15 @@ +-- Engage the LLNotificationsListener LLEventAPI + +leap = require 'leap' + +local LLNotification = {} + +function LLNotification.add(name, substitutions) + leap.send('LLNotifications', {op='requestAdd', name=name, substitutions=substitutions}) +end + +function LLNotification.requestAdd(name, substitutions) + return leap.request('LLNotifications', {op='requestAdd', name=name, substitutions=substitutions})['response'] +end + +return LLNotification diff --git a/indra/newview/scripts/lua/luafloater_speedometer.xml b/indra/newview/scripts/lua/luafloater_speedometer.xml new file mode 100644 index 0000000000..54b99c7d48 --- /dev/null +++ b/indra/newview/scripts/lua/luafloater_speedometer.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<floater + legacy_header_height="18" + height="60" + layout="topleft" + name="lua_speedometer" + title="Speedometer" + can_minimize="false" + width="170"> + <text + type="string" + follows="left|top" + font="SansSerifBold" + font.size="Huge" + text_color="White" + layout="topleft" + top="25" + left_delta="30" + width="70" + height="30" + name="speed_lbl"/> + <text + type="string" + follows="left|top" + width="55" + height="30" + font="SansSerifBold" + font.size="Huge" + text_color="White" + layout="topleft" + left_pad="2" + name="mps_lbl"> + m/s + </text> +</floater> diff --git a/indra/newview/scripts/lua/test_luafloater_speedometer.lua b/indra/newview/scripts/lua/test_luafloater_speedometer.lua new file mode 100644 index 0000000000..a9d3a70330 --- /dev/null +++ b/indra/newview/scripts/lua/test_luafloater_speedometer.lua @@ -0,0 +1,32 @@ +local Floater = require 'Floater' +local leap = require 'leap' +local LLNotification = require 'LLNotification' +local startup = require 'startup' +local Timer = (require 'timers').Timer +local max_speed = 0 +local flt = Floater:new("luafloater_speedometer.xml") +startup.wait('STATE_STARTED') + +local timer + +function flt:floater_close(event_data) + if timer then + timer:cancel() + end + msg = "Registered max speed: " .. string.format("%.2f", max_speed) .. " m/s"; + LLNotification.add('SystemMessageTip', {MESSAGE = msg}) +end + +local function idle(event_data) + local speed = leap.request('LLVOAvatar', {op='getSpeed'})['value'] + flt:post({action="set_value", ctrl_name="speed_lbl", value = string.format("%.2f", speed)}) + max_speed=math.max(max_speed, speed) +end + +msg = 'Are you sure you want to run this "speedometer" script?' +response = LLNotification.requestAdd('GenericAlertYesCancel', {MESSAGE = msg}) + +if response.OK_okcancelbuttons then + flt:show() + timer = Timer:new(1, idle, true) -- iterate +end |