'global' functions? / user library?

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
renerene
Posts: 356
Joined: Wednesday 03 August 2016 11:36
Target OS: -
Domoticz version:
Contact:

'global' functions? / user library?

Post by renerene »

There are some functions that I use in several dzVents scripts. At the moment this is a copy/paste thing.
Question: is it possible to call functions 'outside' the current script and create a central library?
User avatar
jvdz
Posts: 2445
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: 'global' functions? / user library?

Post by jvdz »

I use this in regular LUA scripts to include a file with my standard functions:

Code: Select all

dofile("/home/pi/domoticz/scripts/lua/general_functions.lua")
Assume it works the same in DzVents as they are LUA.

Jos
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: 'global' functions? / user library?

Post by waaren »

jvdz wrote: Friday 04 January 2019 20:12 I use this in regular LUA scripts to include a file with my standard functions:

Code: Select all

dofile("/home/pi/domoticz/scripts/lua/general_functions.lua")
Assume it works the same in DzVents as they are LUA.

Jos
Yes that will work in dzVents but on top of that, dzVents has a kind of builtin mechanism for this; called helper functions
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
renerene
Posts: 356
Joined: Wednesday 03 August 2016 11:36
Target OS: -
Domoticz version:
Contact:

Re: 'global' functions? / user library?

Post by renerene »

Yes that will work in dzVents but on top of that, dzVents has a kind of builtin mechanism for this; called helper functions
Perfect!
Thank you
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest