Hello Guest it is April 13, 2021, 11:56:08 AM

Author Topic: lua panel and modules  (Read 1073 times)

0 Members and 1 Guest are viewing this topic.

lua panel and modules
« on: May 28, 2017, 01:43:44 AM »

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?

Offline DazTheGas

  •  753 753
  • DazTheGas
    • View Profile
Re: lua panel and modules
« Reply #1 on: May 28, 2017, 04:05:09 PM »
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

Code: [Select]
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"


Theres always time for a choccy biccy
Re: lua panel and modules
« Reply #2 on: May 28, 2017, 11:13:00 PM »
Thank you!

Great! So I did the name pollution in the wrong direction.
A sample is always good explanation :)