This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Script.create?
#11
(17.01.2019, 12:59)admin Wrote: Here's an example of how to create script from another script:
Code:
data = {
   -- either event, resident or scheduled
   type = 'event',
   -- unique script name
   name = 'my script',
   -- 1 = active, 0 = inactive
   active = 1,
   -- event script: group address or tag
   -- resident script: sleep time in seconds (0..60)
   -- scheduled script: execution date/time in CRON format
   params = '1/1/1',
   -- set to 1 to enable "execute on read" for event scripts
   -- not used for resident and scheduled scripts
   subparams = 0,
   -- script Lua code
   script = 'log(123)',
   -- optional script category
   category = '',
   -- optional script description
   description = '',
}

-- check for duplicate script with the same name
exists = script.get(data.name)
if not exists then
   db:insert('scripting', data)

   data.id = db:getlastautoid()

   script.save(data, true)
   script.reloadsingle(data)
end

Hi,

I am using this for for 'autosetup' LM with a startup (init) script and it has been very useful. 
Is there any simular way to add functions to 'common functions' (or overwrite the file) ?
Reply


Messages In This Thread
Script.create? - by FatMax - 12.01.2019, 06:52
RE: Script.create? - by Daniel - 14.01.2019, 08:48
RE: Script.create? - by Thomas - 14.01.2019, 11:51
RE: Script.create? - by FatMax - 16.01.2019, 06:28
RE: Script.create? - by Jayce - 17.01.2019, 08:16
RE: Script.create? - by admin - 17.01.2019, 12:59
RE: Script.create? - by epps - 18.04.2020, 18:11
RE: Script.create? - by JohnTH - 17.08.2022, 18:51
RE: Script.create? - by FatMax - 18.01.2019, 07:31
RE: Script.create? - by admin - 19.04.2020, 09:27
RE: Script.create? - by epps - 19.04.2020, 11:12
RE: Script.create? - by admin - 18.08.2022, 06:35
RE: Script.create? - by JohnTH - 18.08.2022, 19:44
RE: Script.create? - by FatMax - 13.09.2023, 21:02
RE: Script.create? - by admin - 14.09.2023, 07:17
RE: Script.create? - by FatMax - 15.09.2023, 12:46

Forum Jump: