Page 1 of 1

Function within dzVents script?

Posted: Saturday 16 May 2020 15:40
by doh
Hi

I have a dzVents script that performs the same tasks 2 or 3 times depending on whether it was triggered by a timer or by one of a number of devices.

Is it possible to define a function within that script which I can call repeatedly for each case?

I know you can create global "helper" functions, but I'd prefer to keep it within the one script file.

Thanks

Re: Function within dzVents script?  [Solved]

Posted: Saturday 16 May 2020 16:22
by dlube
For sure :D
Have a look to the example below

Code: Select all

return {
     ...
	execute = function(dz, item)
          local function myFunction(variable)
               ...
               do your stuff
               ...
               return result1, result2
          end

local a, b = myFunction(myVariable)
...
end
}
you can call this function from your code like you do with helpers.