You're getting a bit confused.. but are almost there
The Load_modules.mcs file is for loading modules into the lua chunk that exists for macros only. This is separate to the chunk that runs the screenload/PLC/signal scripts etc.
To call the module functions from a button you need to include the following at the top of the screenload script as well:
package.loaded.Test = nil
t = require "Test" --This stores the contents of the module into table 't' or a name of your choice
Your module 'Test.lua' should look like this:
local Test = {}
function Test.PrintVal(val)
wx.wxMessageBox("Current val="..tostring(val))
end
function Test.AnotherFunction()
wx.wxMessageBox("This is another function")
end
return Test
Now in your button script you can call the functions like this, note the use of 't' before the function name as this is where we stored them when we 'required' the module
t.PrintVal(val)
t.AnotherFunction()
Because you have also created the Load_modules.mcs and put it in your macros folder, this will load the same module in the macro lua chunk so you can call the functions from your macros (m6, m3 etc) as well. Please note that you cannot use the module to transfer information between the GUI lua chunk and the macro lua chunk, only registers can do this.
Hopefully this helps