| 5279 | } |
| 5280 | |
| 5281 | staticfn int |
| 5282 | get_table_region( |
| 5283 | lua_State *L, |
| 5284 | const char *name, |
| 5285 | lua_Integer *x1, lua_Integer *y1, |
| 5286 | lua_Integer *x2, lua_Integer *y2, |
| 5287 | boolean optional) |
| 5288 | { |
| 5289 | lua_Integer arrlen; |
| 5290 | |
| 5291 | lua_getfield(L, 1, name); |
| 5292 | if (optional && lua_type(L, -1) == LUA_TNIL) { |
| 5293 | lua_pop(L, 1); |
| 5294 | return 1; |
| 5295 | } |
| 5296 | |
| 5297 | luaL_checktype(L, -1, LUA_TTABLE); |
| 5298 | |
| 5299 | lua_len(L, -1); |
| 5300 | arrlen = lua_tointeger(L, -1); |
| 5301 | lua_pop(L, 1); |
| 5302 | if (arrlen != 4) { |
| 5303 | nhl_error(L, "Not a region"); |
| 5304 | /*NOTREACHED*/ |
| 5305 | lua_pop(L, 1); |
| 5306 | return 0; |
| 5307 | } |
| 5308 | |
| 5309 | *x1 = get_table_intarray_entry(L, -1, 1); |
| 5310 | *y1 = get_table_intarray_entry(L, -1, 2); |
| 5311 | *x2 = get_table_intarray_entry(L, -1, 3); |
| 5312 | *y2 = get_table_intarray_entry(L, -1, 4); |
| 5313 | |
| 5314 | lua_pop(L, 1); |
| 5315 | return 1; |
| 5316 | } |
| 5317 | |
| 5318 | boolean |
| 5319 | get_coord(lua_State *L, int i, lua_Integer *x, lua_Integer *y) |
no test coverage detected