栈的操作:https://www.cnblogs.com/lsgxeva/p/11158228.html
print(package.path)
package.path = package.path .. ";E:\\OGL5\\c++calllua\\luascript\\?.lua;"
print("hello")
print(package.path)
require 'person'
c = add(1,4)
print(c)
myName = "beauty girl"
helloTable = {name="xiaoming", age=12}
C++访问lua的table
lua_State* L = luaL_newstate();
luaL_openlibs(L);
luaL_dofile(L, "hello.lua");
ua_getglobal(L, "helloTable");
lua_pushstring(L, "name");
lua_pushstring(L, "age");
lua_gettable(L, -3);
int age = lua_tointeger(L, -1);
const char* sName = lua_tostring(L, -2);
lua_pop(L, 1);
const char* sName2 = lua_tostring(L, -1);
lua_pushinteger(L, 23);
int age2 = lua_tointeger(L, -1);
lua_pushinteger(L, 32);
int count = lua_gettop(L);
lua_settop(L, 2);
int count2 = lua_gettop(L);
lua_close(L);
system("pause");
|