如何解析Lua中的table数据?调用getluavar(luastate,”项目。A.一个“),以获得项目的价值。A.一个放到堆栈上,然后根据类型使用luavarutonumber(luastate,-1)或Luau2;Datavoidgetluavar(Lua)fromtoString(luastate,-1)u2;State*pLuaState,constchar*strVarName){constcharpIndS=strVarNameconstchar*pIndE=strVarNameTub8bparts=false//判断是否分为两部分,因为Lua用于第一部分Getglobal,所以Lua用于其他部分gettablewhile(0!=*pIndE){if(“”==*pIndE){if(bParts){luauuuuPushString(pLuaState,std::string(pIndS,pIndE-pIndS).cuStr())luauGetTable(pLuaState,-2)luauRemove(pLuaState,-2)}else{luauGetGlobal(pLuaState,std::string(pIndS,pIndE-pIndS).cuStr())bParts=true}pIndEpIndS=pIndE}else{pIndE}if(bParts){luaupushstring(pLuaState,std::string(pIndS,pIndE-pIndS).cstr())luaugettable(pLuaState,-2)luauuremove(pLuaState,-2)}else{luauugetglobal(pLuaState,std::string(pIndS,pIndE-pIndS).cstr())}
分享题目:tolua教程如何解析Lua中的table数据?-创新互联
标题链接:
http://bjjierui.cn/article/csiggj.html