[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Error on include/require
- From: David Durant <lua@...>
- Date: Sat, 10 Mar 2007 12:32:07 -0500
New Lua user here. Great stuff, in love with it already!
I'm getting an error when trying to import or require another file.
I've tried:
local Utils = import('Utilities.lua')
and (not at the same time):
require "Utilities"
and they both give an error message:
Error calling function 'Test': attempt to call a nil value
It doesn't seem to matter what's in the file Utilities.lua. It can be
empty and I still get that error.
I've also tried using the entire path to the file. No change.
The LUA_PATH environment variable is set to:
?;?.lua;c:\fxexpert\?;c:\fxexpert\?.lua;;
My C initialization code looks like this:
luaState = lua_open();
luaL_openlibs(luaState);
Then I call Test.lua like this:
luaL_dofile(luaState, "Test.lua");
lua_getglobal(luaState, "Test"); // Lua function to be called
lua_pushlightuserdata(luaState, dllData);
if (lua_pcall(luaState, 1, 0, 0) != 0)
{
char strOut[200];
sprintf_s(strOut, sizeof(strOut) - 1, "Error calling function '%s':
%s", "Test", lua_tostring(luaState, -1));
::MessageBox(NULL, strOut, "Execute", MB_OK | MB_TOPMOST);
return MSX_SUCCESS;
}
If I remove the import and require statements, the Lua code runs fine.
Am I missing something?
Platform = WinXP
Downloaded latest Lua source and compiled (as static lib) myself. Also
tried pre-compiled bins with the same results.
Thanks,
Dave