Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: django013 on May 28, 2017, 01:43:44 AM
-
Hi,
I created a lua panel which works so far. I put the creation of controls in a function, which gets called from lua panel script.
Now I tried to move that function into a lua module - and that fails.
I then thought, that the problem might be related to variable namespaces and extracted all control-variables to global namespace ...
.. but that didn't solve the problem.
As soon as I place the function in a module, only the placeholder for the lua panel gets painted.
Is it possible to populate a lua-panel from a module and if so, what rules do I have to obey?
-
A Lua Panel runs in a private context, it has no access to what has been declared in other scripts within mach4 like the screen load script etc, if you have all your stuff in a module then you need to use the 'require' function within the lua panel.
Heres a very old exampe of the beginning of a lua panel in one of my previous screensets
local inst = mc.mcGetInstance()
local profile = mc.mcProfileGetName(inst)
local path = mc.mcCntlGetMachDir(inst)
package.path = path .. "\\Profiles\\" .. profile .. "\\Modules\\?.lua;"
package.loaded.MasterFunc = nil
mf = require "MasterFunc"
mf.CreatePanel(mcLuaPanelParent)
DazTheGas
-
Thank you!
Great! So I did the name pollution in the wrong direction.
A sample is always good explanation :)