blob: af7189a2cb2297b9ea8e1f5835fa4d6a9d889b66 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
local Floater = require 'Floater'
local leap = require 'leap'
local popup = require 'popup'
local startup = require 'startup'
local Timer = (require 'timers').Timer
local max_speed = 0
local flt = 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_okcancelbuttons then
flt:show()
timer = Timer(1, idle, true) -- iterate
end
|