2

I'm using LuaAlchemy with AS3 and am currently trying to call global function in lua script. Running whole script file works perfectly, but when I try to call callGlobal(), I get Lua error: attempt to call a nil value.

function call:

lua_interpreter.callGlobal("func",3)

lua script:

function func(a)
 return a
end
user1760770
  • 365
  • 5
  • 17
  • Please show how do you load Lua script. Make sure that it is actually loaded (put an `error("loaded")` somewhere, for example and see if it crashes). – Alexander Gladysh Apr 19 '13 at 03:16

1 Answers1

0

I Solved the same problem this way:

[Embed(source="../lua/test.lua", mimeType="application/octet-stream")]
static var _testLuaClass:Class;


static var lua_interpreter:LuaAlchemy = new LuaAlchemy(LuaAssets.filesystemRoot());
static var luaTestAsset:ByteArrayAsset = ByteArrayAsset(new _testLuaClass());

lua_interpreter.doString(luaTestAsset.toString());

trace(lua_interpreter.callGlobal("func",3));

and the Lua script file is the same as yours.