Easy question about variables
Posted: Friday 21 October 2016 16:42
Hi guys,
I have an easy question for the novice user, but i spend a week to get this working so please help me....
The simple thing is that i want to set a variable in the first LUA script to a certain number, lets say 1, then want to read it in the second script and set this variable to another number 2.
It sounds easy but i strangle with the correct notation.
below are parts of the scripts to get an idea:
first script:
if (devicechanged['Status alarm panel'] == 'On' and uservariable['alarm_status'] ~= '2') then
commandArray['Variable:alarm_status'] = tostring(2)
end
second script:
if (devicechanged['test'] == 'On' and uservariables['alarm_status'] == '2') then
commandArray['Variable:alarm_status']= tostring(5)
end
I have made an user variable "alarm_status" as an integer but get error messages like "attempt to index global 'uservariable' (a nil value)"
i have tried things like uservariable == alarm_status or alarm_variable ==2 or uservariable['alarm_variable'] == 2 but nothing works.
It will be much apriciated if someone could setup the basis code.
Thanks in advance
Greetz, Paul
I have an easy question for the novice user, but i spend a week to get this working so please help me....
The simple thing is that i want to set a variable in the first LUA script to a certain number, lets say 1, then want to read it in the second script and set this variable to another number 2.
It sounds easy but i strangle with the correct notation.
below are parts of the scripts to get an idea:
first script:
if (devicechanged['Status alarm panel'] == 'On' and uservariable['alarm_status'] ~= '2') then
commandArray['Variable:alarm_status'] = tostring(2)
end
second script:
if (devicechanged['test'] == 'On' and uservariables['alarm_status'] == '2') then
commandArray['Variable:alarm_status']= tostring(5)
end
I have made an user variable "alarm_status" as an integer but get error messages like "attempt to index global 'uservariable' (a nil value)"
i have tried things like uservariable == alarm_status or alarm_variable ==2 or uservariable['alarm_variable'] == 2 but nothing works.
It will be much apriciated if someone could setup the basis code.
Thanks in advance
Greetz, Paul