I'm trying to write my first variable script for tracking bluetooth beacons.
My variables update fine but I'm trying to get them to toggle some virtual switches... and my script doesn't work.
Please keep it simple as I'm struggling to get a grip on lua

I know it's a bit clunky but here it is
Code: Select all
-- script_variable_bt.lua
commandArray = {}
for variableName,variableValue in pairs(uservariablechanged) do
if (variableName=='Zhenya_Kitchen') then
if variableValue == HOME then
commandArray['ZKitchenBT'] = "On"
end
end
if (variableName=='Zhenya_Kitchen') then
if variableValue == AWAY then
commandArray['ZKitchenBT'] = "Off"
end
end
if (variableName=='Zhenya_Office') then
if variableValue == HOME then
commandArray['ZOfficeBT'] = "On"
end
end
if (variableName=='Zhenya_Office') then
if variableValue == AWAY then
commandArray['ZOfficeBT'] = "Off"
end
end
if (variableName=='Zhenya_Hall') then
if variableValue == HOME then
commandArray['ZHallBT'] = "On"
end
end
if (variableName=='Zhenya_Hall') then
if variableValue == AWAY then
commandArray['ZHallBT'] = "Off"
end
end
if (variableName=='Zhenya_SitRm') then
if variableValue == HOME then
commandArray['ZSitRoomBT'] = "On"
end
end
if (variableName=='Zhenya_SitRm') then
if variableValue == AWAY then
commandArray['ZSitRoomBT'] = "Off"
end
end
end
return commandArray
Sean