您的位置:首页 > 编程语言 > Lua

在C++中为LUA添加PATH路径(搜索路径)

2017-11-10 20:45 323 查看
[cpp] view
plain copy

void LuaAddPath(lua_State *ls, char *name, char *value) {  

    string v;  

  

    lua_getglobal(ls, "package");  

    lua_getfield(ls, -1, name);  

    v.append(lua_tostring(ls, -1));  

    v.append(";");  

    v.append(value);  

    lua_pushstring(ls, v.c_str());  

    lua_setfield(ls, -3, name);  

    lua_pop(ls, 2);  

}  

[cpp] view
plain copy

LuaAddPath(m_ls->GetCState(), "path", ".\\lual\\?.lua");  

LuaAddPath(m_ls->GetCState(), "cpath", ".\\lual\\?.dll");
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: