proto-debuger/protoDebuger/lua_wraper.h

38 lines
678 B
C
Raw Normal View History

2021-04-04 18:32:21 +00:00
#ifndef LUA_WRAPER_H
#define LUA_WRAPER_H
#include <string.h>
extern "C" {
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
}
void TestLua(){
char buff[256];
int error;
lua_State *L = luaL_newstate(); //打开lua
if(nullptr != L){
printf("shit is nullptr");
}
luaL_openlibs(L); //打开标准库
2021-04-13 17:28:19 +00:00
int ret = luaL_dofile(L, "Test.lua");
if (ret > 0){
printf("lua error");
}
int sum;
//code5
lua_getglobal(L, "add");
//code6
char * data = "hell";
lua_pushstring(L, data);
//code7
lua_pushnumber(L, 4);
//code8
lua_call(L, 2, 1);
2021-04-04 18:32:21 +00:00
lua_close(L);
}
#endif // LUA_WRAPER_H