增加luaApi_HttpGet和luaApi_HttpPost
This commit is contained in:
@@ -44,6 +44,10 @@ auto initLuaScripts() -> void {
|
||||
lua_State* L = luaL_newstate();
|
||||
|
||||
luaL_openlibs(L);
|
||||
|
||||
luaL_requiref(L, "cjson", luaopen_cjson, 1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
ScriptApis::initFunciton(L);
|
||||
|
||||
pluginEnvs[dirName] = L;
|
||||
@@ -59,15 +63,20 @@ auto initLuaScripts() -> void {
|
||||
|
||||
std::string scriptDir = dirPath;
|
||||
lua_getglobal(L, "package");
|
||||
lua_getfield(L, -1, "path"); // get field "path" from table at top of stack (-1)
|
||||
std::string cur_path = lua_tostring(L, -1); // grab path string from top of stack
|
||||
cur_path.append(";"); // do your path magic here
|
||||
lua_getfield(
|
||||
L, -1, "path"); // get field "path" from table at top of stack (-1)
|
||||
std::string cur_path =
|
||||
lua_tostring(L, -1); // grab path string from top of stack
|
||||
cur_path.append(";"); // do your path magic here
|
||||
cur_path.append(scriptDir);
|
||||
cur_path.append("\\?.lua");
|
||||
lua_pop(L, 1); // get rid of the string on the stack we just pushed on line 5
|
||||
lua_pushstring(L, cur_path.c_str()); // push the new one
|
||||
lua_setfield(L, -2, "path"); // set the field "path" in table at -2 with value at top of stack
|
||||
lua_pop(L, 1); // get rid of package table from top of stack
|
||||
lua_pop(
|
||||
L,
|
||||
1); // get rid of the string on the stack we just pushed on line 5
|
||||
lua_pushstring(L, cur_path.c_str()); // push the new one
|
||||
lua_setfield(L, -2, "path"); // set the field "path" in table at -2
|
||||
// with value at top of stack
|
||||
lua_pop(L, 1); // get rid of package table from top of stack
|
||||
|
||||
if (luaL_dofile(L, file.c_str())) {
|
||||
LOG("dofile_err:%s\n\n", lua_tostring(L, -1));
|
||||
|
||||
Reference in New Issue
Block a user