/***************************************************C++ main.cpp**************************************************/
#include <iostream>
#include <stdio.h>#include <stdlib.h>
#include "lua.hpp"
using namespace std;
int FOO = LUA_REFNIL;
int dosomething(lua_State *L)
{
cout << "insid c code" << endl;
FOO = luaL_ref(L, LUA_REGISTRYINDEX); //将从Lua脚本中传入的Lua函数保存起来
return 0;
}
int main()
{
lua_State *L = luaL_newstate();
luaL_openlibs(L);
lua_register(L, "dosomething", dosometh