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

Function lspo_engraving

src/sp_lev.c:3880–3936  ·  view source on GitHub ↗

engraving({ x = 1, y = 1, type="burn", text="Foo" }); */ engraving({ coord={1, 1}, type="burn", text="Foo" }); */ engraving({x,y}, "engrave", "Foo"); */

Source from the content-addressed store, hash-verified

3878/* engraving({ coord={1, 1}, type="burn", text="Foo" }); */
3879/* engraving({x,y}, "engrave", "Foo"); */
3880int
3881lspo_engraving(lua_State *L)
3882{
3883 static const char *const engrtypes[] = {
3884 "dust", "engrave", "burn", "mark", "blood", NULL
3885 };
3886 static const int engrtypes2i[] = {
3887 DUST, ENGRAVE, BURN, MARK, ENGR_BLOOD, 0
3888 };
3889 int etyp = DUST;
3890 char *txt = (char *) 0;
3891 long ecoord;
3892 coordxy x = -1, y = -1;
3893 int argc = lua_gettop(L);
3894 boolean guardobjs = FALSE;
3895 boolean wipeout = TRUE;
3896 struct engr *ep;
3897
3898 create_des_coder();
3899
3900 if (argc == 1) {
3901 lua_Integer ex, ey;
3902 lcheck_param_table(L);
3903
3904 get_table_xy_or_coord(L, &ex, &ey);
3905 x = ex;
3906 y = ey;
3907 etyp = engrtypes2i[get_table_option(L, "type", "engrave", engrtypes)];
3908 txt = get_table_str(L, "text");
3909 wipeout = get_table_boolean_opt(L, "degrade", TRUE);
3910 guardobjs = get_table_boolean_opt(L, "guardobjects", FALSE);
3911 } else if (argc == 3) {
3912 lua_Integer ex, ey;
3913 (void) get_coord(L, 1, &ex, &ey);
3914 x = ex;
3915 y = ey;
3916 etyp = engrtypes2i[luaL_checkoption(L, 2, "engrave", engrtypes)];
3917 txt = dupstr(luaL_checkstring(L, 3));
3918 } else {
3919 nhl_error(L, "Wrong parameters");
3920 }
3921
3922 if (x == -1 && y == -1)
3923 ecoord = SP_COORD_PACK_RANDOM(0);
3924 else
3925 ecoord = SP_COORD_PACK(x, y);
3926
3927 get_location_coord(&x, &y, DRY, gc.coder->croom, ecoord);
3928 make_engr_at(x, y, txt, NULL, 0L, etyp);
3929 Free(txt);
3930 ep = engr_at(x, y);
3931 if (ep) {
3932 ep->guardobjects = guardobjs;
3933 ep->nowipeout = !wipeout;
3934 }
3935 return 0;
3936}
3937

Callers

nothing calls this directly

Calls 12

create_des_coderFunction · 0.85
lcheck_param_tableFunction · 0.85
get_table_xy_or_coordFunction · 0.85
get_table_optionFunction · 0.85
get_table_strFunction · 0.85
get_table_boolean_optFunction · 0.85
get_coordFunction · 0.85
dupstrFunction · 0.85
nhl_errorFunction · 0.85
get_location_coordFunction · 0.85
make_engr_atFunction · 0.85
engr_atFunction · 0.85

Tested by

no test coverage detected