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

Function lspo_grave

src/sp_lev.c:4242–4278  ·  view source on GitHub ↗

grave(); */ grave(x,y, "text"); */ grave({ x = 1, y = 1 }); */ grave({ x = 1, y = 1, text = "Foo" }); */ grave({ coord = {1, 1}, text = "Foo" }); */

Source from the content-addressed store, hash-verified

4240/* grave({ x = 1, y = 1, text = "Foo" }); */
4241/* grave({ coord = {1, 1}, text = "Foo" }); */
4242int
4243lspo_grave(lua_State *L)
4244{
4245 int argc = lua_gettop(L);
4246 coordxy x, y;
4247 long scoord;
4248 lua_Integer ax,ay;
4249 char *txt;
4250
4251 create_des_coder();
4252
4253 if (argc == 3) {
4254 x = ax = luaL_checkinteger(L, 1);
4255 y = ay = luaL_checkinteger(L, 2);
4256 txt = dupstr(luaL_checkstring(L, 3));
4257 } else {
4258 lcheck_param_table(L);
4259
4260 get_table_xy_or_coord(L, &ax, &ay);
4261 x = ax, y = ay;
4262 txt = get_table_str_opt(L, "text", NULL);
4263 }
4264
4265 if (x == -1 && y == -1)
4266 scoord = SP_COORD_PACK_RANDOM(0);
4267 else
4268 scoord = SP_COORD_PACK(ax, ay);
4269
4270 get_location_coord(&x, &y, DRY, gc.coder->croom, scoord);
4271
4272 if (isok(x, y) && !t_at(x, y)) {
4273 levl[x][y].typ = GRAVE;
4274 make_grave(x, y, txt); /* note: 'txt' might be Null */
4275 }
4276 Free(txt);
4277 return 0;
4278}
4279
4280/* altar({ x=NN, y=NN, align=ALIGNMENT, type=SHRINE }); */
4281/* des.altar({ coord = {5, 10}, align="noalign", type="altar" }); */

Callers

nothing calls this directly

Calls 9

create_des_coderFunction · 0.85
dupstrFunction · 0.85
lcheck_param_tableFunction · 0.85
get_table_xy_or_coordFunction · 0.85
get_table_str_optFunction · 0.85
get_location_coordFunction · 0.85
isokFunction · 0.85
t_atFunction · 0.85
make_graveFunction · 0.85

Tested by

no test coverage detected