1、040-为脚本接口添加错误处理及显示错误信息2021在线班郁金香灬老师 QQ 150330575交流群:158280115学习目标: 为脚本接口添加错误处理及显示错误信息 00A47C80 00A47BF8 assert00A47C84 00854810 00A47C88 00A47BE8 collectgarbage00A47C8C 008545C0 00A47C90 00A0C408 error00A47C94 00854210 00A47C98 00A47BE0 gcinfo00A47C9C 00854590 00A47CA0 00A47BD8 getfenv00A47CA4 00854
2、3E0 00A47CA8 00A47BC8 getmetatable00A47CAC 00854270 00A47CB0 00A47BBC loadstring00A47CB4 008547B0 wow.luaB_loadstring00A47CB8 00A47BB4 next00A47CBC 00854690 00A47CC0 00A47BAC pcall00A47CC4 00854980 00A47CC8 00A47BA0 rawequal00A47CCC 008544D0 00A47CD0 00A47B98 rawget00A47CD4 00854510 00A47CD8 00A47B9
3、0 rawset00A47CDC 00854550 00A47CE0 00A47B88 select00A47CE4 008548F0 00A47CE8 00A47B80 setfenv00A47CEC 00854430 00A47CF0 00A47B70 setmetatable00A47CF4 008542C0 00A47CF8 00A47B64 tonumber00A47CFC 00854100 00A47D00 00A47B58 tostring00A47D04 00854A20 00A47D08 009EBA24 type00A47D0C 00854660 00A47D10 00A4
4、7B50 unpack00A47D14 00854860 00A47D18 00A47B48 xpcall00A47D1C 008549D0 00A47D20 00000000 00A47D24 00000000 00A47D28 00A47B40 create00A47D2C 00854DA0 00A47D30 00A47B38 resume00A47D34 00854CB0 00A47D38 00A47B30 running00A47D3C 00854F20 00A47D40 009F13F4 status00A47D44 00854E50 00A47D48 00A47B28 wrap00
5、A47D4C 00854E00 00A47D50 00A47B20 yield00A47D54 00854E30 00A47D58 00000000 00A47D5C 00000000 00A47D60 65736162 int luaL_dostring_utf8(UINT_PTR L指针, const char*strlua)/DWORD AnsiToUtf8(IN LPCSTR Ansi, OUT LPSTR szpUtf8Buf, SIZE_T bufsize);/ANSI字符转换成utf8格式size_t 长度 = strlen(strlua);int iret = 0; int i
6、top=lua_gettop(L指针); _tryprintf(luaL_dostring_utf8 itop=%d,行号=%dn, itop, _LINE_);int iret2=luaL_loadstring(L指针, strlua);if (iret2)size_t len = 0;const char* msg = lua_tolstring(L指针, 1, &len);printf(脚本出错信息:%sn, msg); printf(luaB_loadstring iret2=%d itop=%d,行号=%dn, iret2, itop, _LINE_);iret = lua_pcal
7、l(L指针, 0, LUA_MULTRET, 0);if (iret)size_t len = 0;const char* msg = lua_tolstring(L指针, 1, &len);printf(脚本出错信息:%sn, msg);printf(luaL_dostring_utf8 itop=%d,pcall ret=%d 行号=%d +*+ n, itop,iret, _LINE_);_except (1)MessageBoxA(0, Error luaL_dostring_utf8, ERROR, MB_OK);lua_settop(L指针, itop);printf(luaL_dostring_utf8 itop=%d,行号=%d + pcall okn, itop, _LINE_);return iret;