<?xml version="1.0" encoding="utf-8"?>
<luaLibraries>
<luaLibrary name="callforward">
<code><![CDATA[
local valid = false
local active = config.get( pathPrefix .. "active" )
local function updateLed()
if not valid then
key:setLed( "red", true )
elseif active == "true" then
key:setLed( "green" )
else
key:setLed( "off" )
end
end
local function checkValid()
local value = config.get( pathPrefix .. "target" )
valid = value and value:len() > 0
end
local function checkActive()
active = config.get( pathPrefix .. "active" )
end
local function configListener( path )
checkValid()
checkActive()
updateLed()
end
function onKeyUp()
--[] check for validity []--
if not valid then
return
end
local value = config.get( pathPrefix .. "active" )
if value == "false" then
config.set( pathPrefix .. "active", "true" )
elseif value == "true" then
config.set( pathPrefix .. "active", "false" )
end
end
config.register( pathPrefix, configListener )
checkValid()
updateLed()--]]></code>
</luaLibrary>
</luaLibraries>