71
Mach4 General Discussion / Re: Using Modules
« on: May 29, 2016, 08:15:53 PM »
Maybe a step in the right direction. When I run the code below in the editor...
It opens a file dialog with Module1.lua already entered. I click open and the module opens up allowing me to step through it. When it gets to the bottom of the module, it returns to the calling script. The next line in the script is the call to theFunction(), which generates this error.
Code: [Select]
inst = mc.mcGetInstance()
local profile = mc.mcProfileGetName(inst)
local path = mc.mcCntlGetMachDir(inst)
package.path = path .. "\\Profiles\\" .. profile .. "\\Modules\\?.lua;" .. path .. "\\Modules\\?.lua;"
local M = require "Module1"
local rc = theFunction()
It opens a file dialog with Module1.lua already entered. I click open and the module opens up allowing me to step through it. When it gets to the bottom of the module, it returns to the calling script. The next line in the script is the call to theFunction(), which generates this error.
Code: [Select]
mcLua ERROR: Lua: Error while running chunk
[string "C:\Users\Richard\AppData\Local\Temp\le4431.mc..."]:6: attempt to call global 'theFunction' (a nil value)