MCPcopy Create free account
hub / github.com/NetHack/NetHack / l_get_lregion

Function l_get_lregion

src/sp_lev.c:5409–5436  ·  view source on GitHub ↗

get params from topmost lua hash: - region = {x1,y1,x2,y2} - exclude = {x1,y1,x2,y2} (optional) - region_islev=true, exclude_islev=true (optional) - negative x and y are invalid */

Source from the content-addressed store, hash-verified

5407 - region_islev=true, exclude_islev=true (optional)
5408 - negative x and y are invalid */
5409staticfn void
5410l_get_lregion(lua_State *L, lev_region *tmplregion)
5411{
5412 lua_Integer x1,y1,x2,y2;
5413
5414 get_table_region(L, "region", &x1, &y1, &x2, &y2, FALSE);
5415 tmplregion->inarea.x1 = x1;
5416 tmplregion->inarea.y1 = y1;
5417 tmplregion->inarea.x2 = x2;
5418 tmplregion->inarea.y2 = y2;
5419
5420 x1 = y1 = x2 = y2 = -1;
5421 get_table_region(L, "exclude", &x1, &y1, &x2, &y2, TRUE);
5422 tmplregion->delarea.x1 = x1;
5423 tmplregion->delarea.y1 = y1;
5424 tmplregion->delarea.x2 = x2;
5425 tmplregion->delarea.y2 = y2;
5426
5427 tmplregion->in_islev = get_table_boolean_opt(L, "region_islev", 0);
5428 tmplregion->del_islev = get_table_boolean_opt(L, "exclude_islev", 0);
5429
5430 /* if x1 is still negative, exclude wasn't specified, so we should treat
5431 * it as if there is no exclude region at all. Force exclude_islev to
5432 * true so the -1,-1,-1,-1 region is safely off the map and won't
5433 * interfere with branch or portal placement. */
5434 if (x1 < 0)
5435 tmplregion->del_islev = TRUE;
5436}
5437
5438/* teleport_region({ region = { x1,y1, x2,y2 } }); */
5439/* teleport_region({ region = { x1,y1, x2,y2 }, [ region_islev = 1, ]

Callers 2

lspo_teleport_regionFunction · 0.85
lspo_levregionFunction · 0.85

Calls 2

get_table_regionFunction · 0.85
get_table_boolean_optFunction · 0.85

Tested by

no test coverage detected