首页 > 解决方案 > 将字符串向量推送到lua

问题描述

我试图推动字符串向量。但不知何故它返回 nil

它是我的代码:

static int Lua_Extract(lua_State* L) {

std::vector<std::string> foundedEvents;
foundedEvents.push_back("xx");

lua_createtable(L, foundedEvents.size(), 0);
        int newTable = lua_gettop(L);
        for (size_t i = 1; i < foundedEvents.size(); i++)
        {
            lua_pushstring(L, foundedEvents[i].c_str());
            lua_rawseti(L, newTable, i);
        }
return 1;
}

标签: c++lua

解决方案


推荐阅读