summaryrefslogtreecommitdiff
path: root/indra/newview/scripts/lua
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/scripts/lua')
-rw-r--r--indra/newview/scripts/lua/test_luafloater_speedometer.lua16
1 files changed, 11 insertions, 5 deletions
diff --git a/indra/newview/scripts/lua/test_luafloater_speedometer.lua b/indra/newview/scripts/lua/test_luafloater_speedometer.lua
index 610401ae44..a9d3a70330 100644
--- a/indra/newview/scripts/lua/test_luafloater_speedometer.lua
+++ b/indra/newview/scripts/lua/test_luafloater_speedometer.lua
@@ -1,18 +1,23 @@
local Floater = require 'Floater'
+local leap = require 'leap'
+local LLNotification = require 'LLNotification'
local startup = require 'startup'
-inspect = require 'inspect'
-leap = require 'leap'
-LLNotification = require 'LLNotification'
+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
-function flt:idle(event_data)
+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)
@@ -22,5 +27,6 @@ msg = 'Are you sure you want to run this "speedometer" script?'
response = LLNotification.requestAdd('GenericAlertYesCancel', {MESSAGE = msg})
if response.OK_okcancelbuttons then
- flt:show()
+ flt:show()
+ timer = Timer:new(1, idle, true) -- iterate
end