diff options
Diffstat (limited to 'indra/newview/scripts/lua/test_luafloater_speedometer.lua')
-rw-r--r-- | indra/newview/scripts/lua/test_luafloater_speedometer.lua | 31 |
1 files changed, 31 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..2cdd41fd7e --- /dev/null +++ b/indra/newview/scripts/lua/test_luafloater_speedometer.lua @@ -0,0 +1,31 @@ +local leap = require 'leap' +local startup = require 'startup' +local Timer = (require 'timers').Timer +local UI = require 'UI' +local popup = UI.popup +local max_speed = 0 +local flt = UI.Floater("luafloater_speedometer.xml") +startup.wait('STATE_STARTED') + +local timer + +function flt:floater_close(event_data) + if timer then + timer:cancel() + end + popup:tip(string.format("Registered max speed: %.2f m/s", max_speed)) +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 = popup:alertYesCancel(msg) + +if response == 'OK' then + flt:show() + timer = Timer(1, idle, true) -- iterate +end |