3
在我的應用程序中我想在加載lua腳本之前在Lua中加載基礎庫。嵌入式Lua C++:我如何從C++端加載多個lua模塊
例如:
testLib.lua
A = 5
B = 6
function foo(a,b)
return a+b
end
test.lua
c = foo(A,B)
在我的C++模塊,我想這樣做
// load the lib
luaL_loadbuffer(L, libText, libSize, "testLib");
// run it so that the globals are known
lua_pcall(L,0,0,0);
// load the main script that uses the lib function and variables
luaL_loadbuffer(L, progText, progSize, "testLib");
// run it
lua_pcall(L,0,0,0);
這裏我得到一個錯誤t帽子功能'foo'未知
有沒有辦法在同一個lua狀態下加載多個Lua模塊?
感謝您的幫助提前
馬庫斯您好,感謝重播的例子。問題是,我不想重新編譯C++模塊。腳本位於SD卡上。所以綁定函數是沒有選擇的。 – 2012-02-23 15:58:58