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

Function get_table_xy_or_coord

src/sp_lev.c:3187–3204  ·  view source on GitHub ↗

Get x and y values from a table (which the caller has already checked for * the existence of), handling both a table with x= and y= specified and a * table with coord= specified. * Returns absolute rather than map-relative coordinates; the caller of this * function must decide if it wants to interpret the coordinates as * map-relative and adjust accordingly. */

Source from the content-addressed store, hash-verified

3185 * function must decide if it wants to interpret the coordinates as
3186 * map-relative and adjust accordingly. */
3187staticfn void
3188get_table_xy_or_coord(
3189 lua_State *L,
3190 lua_Integer *x,
3191 lua_Integer *y)
3192{
3193 lua_Integer mx = get_table_int_opt(L, "x", -1);
3194 lua_Integer my = get_table_int_opt(L, "y", -1);
3195
3196 if (mx == -1 && my == -1) {
3197 lua_getfield(L, 1, "coord");
3198 (void) get_coord(L, -1, &mx, &my);
3199 lua_pop(L, 1);
3200 }
3201
3202 *x = mx;
3203 *y = my;
3204}
3205
3206/* monster(); */
3207/* monster("wood nymph"); */

Callers 15

lspo_monsterFunction · 0.85
lspo_objectFunction · 0.85
lspo_engravingFunction · 0.85
lspo_roomFunction · 0.85
l_create_stairwayFunction · 0.85
lspo_graveFunction · 0.85
lspo_altarFunction · 0.85
lspo_trapFunction · 0.85
lspo_goldFunction · 0.85
lspo_doorFunction · 0.85
lspo_featureFunction · 0.85
lspo_gas_cloudFunction · 0.85

Calls 2

get_table_int_optFunction · 0.85
get_coordFunction · 0.85

Tested by

no test coverage detected