| 270 | } |
| 271 | |
| 272 | static bool getNumberInTable(lua_State *L, const char* pKey, double &ret) { |
| 273 | // 在table里,取指定pKey对应的一个number值 |
| 274 | |
| 275 | //默认栈顶是table,将pKey入栈 |
| 276 | lua_pushstring(L, pKey); |
| 277 | lua_gettable(L, -2); //查找键值为key的元素,置于栈顶 |
| 278 | if (!lua_isnumber(L, -1)) { |
| 279 | LogPrint(BCLog::LUAVM, "num get error! %s\n", lua_tostring(L, -1)); |
| 280 | lua_pop(L, 1); //删掉产生的查找结果 |
| 281 | return false; |
| 282 | } else { |
| 283 | ret = lua_tonumber(L, -1); |
| 284 | // LogPrint(BCLog::LUAVM, "getNumberInTable:%d\n", ret); |
| 285 | lua_pop(L, 1); //删掉产生的查找结果 |
| 286 | return true; |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | static bool getStringInTable(lua_State *L, const char * pKey, string &strValue) { |
| 291 | // 在table里,取指定pKey对应的string值 |
no test coverage detected