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

Function l_selection_rndcoord

src/nhlsel.c:406–428  ·  view source on GitHub ↗

local pt = selection.rndcoord(sel); */ local pt = selection.rndcoord(sel, 1); */

Source from the content-addressed store, hash-verified

404/* local pt = selection.rndcoord(sel); */
405/* local pt = selection.rndcoord(sel, 1); */
406staticfn int
407l_selection_rndcoord(lua_State *L)
408{
409 struct selectionvar *sel = l_selection_check(L, 1);
410 int removeit = (int) luaL_optinteger(L, 2, 0);
411 coordxy x = -1, y = -1;
412 selection_rndcoord(sel, &x, &y, removeit);
413 if (!(x == -1 && y == -1)) {
414 update_croom();
415 if (gc.coder && gc.coder->croom) {
416 x -= gc.coder->croom->lx;
417 y -= gc.coder->croom->ly;
418 } else {
419 x -= gx.xstart;
420 y -= gy.ystart;
421 }
422 }
423 lua_settop(L, 0);
424 lua_newtable(L);
425 nhl_add_table_entry_int(L, "x", x);
426 nhl_add_table_entry_int(L, "y", y);
427 return 1;
428}
429
430/* local s = selection.room(); */
431staticfn int

Callers

nothing calls this directly

Calls 4

l_selection_checkFunction · 0.85
selection_rndcoordFunction · 0.85
update_croomFunction · 0.85
nhl_add_table_entry_intFunction · 0.85

Tested by

no test coverage detected