| 2188 | } |
| 2189 | |
| 2190 | int GetTableIntValue(lua_State* L, int table_index, const char* key, int default_value) |
| 2191 | { |
| 2192 | DM_LUA_STACK_CHECK(L, 0); |
| 2193 | int r = default_value; |
| 2194 | |
| 2195 | lua_getfield(L, table_index, key); |
| 2196 | if (!lua_isnil(L, -1)) { |
| 2197 | |
| 2198 | int actual_lua_type = lua_type(L, -1); |
| 2199 | if (actual_lua_type != LUA_TNUMBER) { |
| 2200 | dmLogError("Lua conversion expected table key '%s' to be a number but got %s", |
| 2201 | key, lua_typename(L, actual_lua_type)); |
| 2202 | } else { |
| 2203 | r = lua_tointeger(L, -1); |
| 2204 | } |
| 2205 | |
| 2206 | } |
| 2207 | lua_pop(L, 1); |
| 2208 | return r; |
| 2209 | } |
| 2210 | |
| 2211 | bool CheckBoolean(lua_State* L, int index) |
| 2212 | { |