日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > php教程 > [置頂] lua進階8-- C++讀取lua文件里的三維表

[置頂] lua進階8-- C++讀取lua文件里的三維表

來源:程序員人生   發布時間:2015-03-28 08:11:57 閱讀次數:2776次

前面lua進階里面講到用C++讀取2維表,但是最近又有了新的需求,lua文件里面出現了3維表,自己摸索了1下,終究找到了解決的方式,在這里面與大家分享1下</span>

我的lua文件里面的3維表結構以下

stage = { {m_nId = 105,m_nBoss = 0,m_nScoreList = {300,450,600},m_nRewardList = {230401201,13020801,13010411},m_nDropItemList = {0,0,0}}, {m_nId = 106,m_nBoss = 0,m_nScoreList = {630,840,1050},m_nRewardList = {241801101,14000201,18000201},m_nDropItemList = {14000101,241700301,230501301}}, {m_nId = 107,m_nBoss = 0,m_nScoreList = {735,980,1225},m_nRewardList = {230400201,230400411,230500101},m_nDropItemList = {12020101,13010301,230401401}}, {m_nId = 108,m_nBoss = 0,m_nScoreList = {840,1120,1400},m_nRewardList = {19000101,241500901,18040201},m_nDropItemList = {14000401,230401201,14000101}}, {m_nId = 109,m_nBoss = 0,m_nScoreList = {1080,1440,1800},m_nRewardList = {12020301,230600101,241800501},m_nDropItemList = {16000401,230901101,230700301}}, {m_nId = 110,m_nBoss = 1,m_nScoreList = {1200,1600,2000},m_nRewardList = {0,0,220200901},m_nDropItemList = {230902101,231101101,231000401}}
};


讀取代碼以下


#include <stdio.h> extern "C"{ #include "lua.h" #include "lualib.h" #include "lauxlib.h" } #include <iostream> #include <vector> #include "string.h" using namespace std; int main ( int argc, char *argv[] ) { lua_State* L; L=lua_open(); luaopen_base(L); luaopen_table(L); luaopen_string(L); luaopen_math(L); if (luaL_dofile(L, "stage.lua")) { printf("run script failed "); } else { int it_idx; int t_idx; lua_getglobal(L,"stage"); t_idx=lua_gettop(L); cout << t_idx << endl; lua_pushnil(L); while(lua_next(L,t_idx)) { it_idx=lua_gettop(L); lua_pushnil(L); //cout << "it_idx = " << it_idx << endl; int m_id = 0; while(lua_next(L,it_idx)) { const char* strkey = lua_tostring(L,⑵); if (strcmp(strkey, "m_nId") == 0) { m_id = (int)lua_tonumber(L, ⑴); cout << "m_id = " <<m_id << " "; } if (strcmp(strkey, "m_nBoss") == 0) { m_id = (int)lua_tonumber(L, ⑴); cout << "m_nBoss = " << m_id << " "; } if (strcmp(strkey, "m_nScoreList") == 0) { if (lua_istable(L, ⑴)) { cout << "m_nScoreList = " ; int ll_idx = lua_gettop(L); //cout << "ll_idx = " << ll_idx << endl; lua_pushnil(L); while (lua_next(L, ll_idx)) { cout << (int)lua_tonumber(L, ⑴) << " "; lua_pop(L, 1); } } } if (strcmp(strkey, "m_nRewardList") == 0) { if (lua_istable(L, ⑴)) { cout << " m_nRewardList = " ; int ll_idx = lua_gettop(L); // cout << "ll_idx = " << ll_idx << endl; lua_pushnil(L); while (lua_next(L, ll_idx)) { cout << (int)lua_tonumber(L, ⑴) <<" "; lua_pop(L, 1); } } } if (strcmp(strkey, "m_nDropItemList") == 0) { if (lua_istable(L, ⑴)) { cout << " m_nDropItemList = "; int ll_idx = lua_gettop(L); // cout << "ll_idx = " << ll_idx << endl; lua_pushnil(L); while (lua_next(L, ll_idx)) { cout << (int)lua_tonumber(L, ⑴) << " "; lua_pop(L, 1); } } } lua_pop(L,1); } cout << endl; lua_pop(L,1); //break; } } lua_close(L); return 0; }




生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 国产精品久久久久久久久久新婚 | 深夜视频一区二区 | 久久精品国产v日韩v亚洲 | 精品国产1区2区 | 男女在线免费视频 | 国产精品无码专区在线观看 | 亚洲国产一区二区在线 | 国产免费小视频 | 爱情岛论坛首页永久网址 | 日本免费看 | 亚洲精品高清视频 | 亚洲色图15p| 中文字幕在线免费 | a久久天堂国产毛片精品 | 久久久久亚洲精品国产 | 午夜在线一区 | 国产成人免费看一级大黄 | 一区二区激情 | 免费毛片大全 | 精品一区在线 | 国产一区二区三区免费观看视频 | 国产三级网站 | 欧美专区一区 | 久久久久久国产精品免费免费 | 亚洲a网站| 99国产精品视频免费观看 | 日韩在线精品视频 | 日本一区二区不卡视频 | www.99热这里只有精品 | 日本77777| 黄色a视频在线观看 | 欧美亚洲日本国产 | 成人精品视频99在线观看免费 | 国产在线一区二区三区视频 | 日韩一区在线视频 | 国产一区不卡 | 久久机 | 91精品久久久久久久99蜜桃 | 国产成人免费av一区二区午夜 | 中文字幕福利片 | yw.139尤物在线精品视频 |