MCPcopy Index your code
hub / github.com/NetHack/NetHack / l_obj_bury

Function l_obj_bury

src/nhlobj.c:602–627  ·  view source on GitHub ↗

bury an obj. returns true if object is gone (merged with ground), false otherwise. */ local ogone = o:bury(); */ local ogone = o:bury(5,5); */

Source from the content-addressed store, hash-verified

600/* local ogone = o:bury(); */
601/* local ogone = o:bury(5,5); */
602staticfn int
603l_obj_bury(lua_State *L)
604{
605 int argc = lua_gettop(L);
606 boolean dealloced = FALSE;
607 struct _lua_obj *lo = l_obj_check(L, 1);
608 coordxy x = 0, y = 0;
609
610 if (argc == 1) {
611 x = lo->obj->ox;
612 y = lo->obj->oy;
613 } else if (argc == 3) {
614 x = (coordxy) lua_tointeger(L, 2);
615 y = (coordxy) lua_tointeger(L, 3);
616 cvt_to_abscoord(&x, &y);
617 } else
618 nhl_error(L, "l_obj_bury: Wrong args");
619
620 if (lobj_is_ok(lo) && isok(x, y)) {
621 lo->obj->ox = x;
622 lo->obj->oy = y;
623 (void) bury_an_obj(lo->obj, &dealloced);
624 }
625 lua_pushboolean(L, dealloced);
626 return 1;
627}
628
629static const struct luaL_Reg l_obj_methods[] = {
630 { "new", l_obj_new_readobjnam },

Callers

nothing calls this directly

Calls 5

l_obj_checkFunction · 0.85
cvt_to_abscoordFunction · 0.85
nhl_errorFunction · 0.85
isokFunction · 0.85
bury_an_objFunction · 0.85

Tested by

no test coverage detected