summaryrefslogtreecommitdiff
path: root/indra/newview/scripts/lua/test_luafloater_speedometer.lua
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-06-20 13:58:20 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-06-20 13:58:20 -0400
commit100a1d95f0e1aa28d6398fe3401a5cf4d19b133e (patch)
treed347ddd496745c7cf722dfe36554d1e365a7a77c /indra/newview/scripts/lua/test_luafloater_speedometer.lua
parent350225e54ba02a7523e17106936a4ce44af91e55 (diff)
parentd7d18aaad0e7b8412e50fd82d446d31611207175 (diff)
Merge branch 'release/luau-scripting' into lua-login
Diffstat (limited to 'indra/newview/scripts/lua/test_luafloater_speedometer.lua')
-rw-r--r--indra/newview/scripts/lua/test_luafloater_speedometer.lua32
1 files changed, 32 insertions, 0 deletions
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