Sharing global variables between extension script and interface script

Discuss your Lua playlist, album art and interface scripts.
ophirhan
New Cone
New Cone
Posts: 2
Joined: 18 May 2021 10:26

Sharing global variables between extension script and interface script

Postby ophirhan » 20 Jun 2021 13:57

Hi! I need to share a table between my extension script located in lua/extensions and my interface script located in lua/intf.
Currently I'm using the ingenious method used in time v3.2 (writing the table to a files, and reading it on the other side), But repetitive IO operations are bad.

I've read online that lua has a global table _G shared between scripts, but whatever reason _G in the extension and _G in the interface are two separate tables.
interface:

Code: Select all

_G.temp = "message"
extension:

Code: Select all

function activate() vlc.msg.info(_G.temp) end
in the extension _G.temp evaluates to nil and crashes it, why?

as an alternative is it possible to signal the interface from the extension whenever it updates the file? using https://luaposix.github.io/luaposix/mod ... ignal.html library maybe?

Thank you :D

mederi
Big Cone-huna
Big Cone-huna
Posts: 1951
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

Re: Sharing global variables between extension script and interface script

Postby mederi » 24 Jun 2021 18:36

method used in time v3.2 (writing the table to a files, and reading it on the other side)
The Time Extension just uses VLC confing system to store its own settings reliably. I believe it is fast in-memory process. The Extension itself does not read/write files. It is meant to store only few settings from the extension script as it allows an interaction with users through dialog box window. Then Time interface script reads these settings frequently during playback so changes can be applied immediately.

vlc.msg.info(tostring(_G.temp))
Whatever working solutions you find and share, the VLC community will be happier :)


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 5 guests