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

Function lspo_object

src/sp_lev.c:3556–3755  ·  view source on GitHub ↗

object(); */ object("sack"); */ object("scimitar", 6,7); */ object("scimitar", {6,7}); */ object({ class = "%" }); */ object({ id = "boulder", x = 03, y = 12}); */ object({ id = "boulder", coord = {03,12} }); */

Source from the content-addressed store, hash-verified

3554/* object({ id = "boulder", x = 03, y = 12}); */
3555/* object({ id = "boulder", coord = {03,12} }); */
3556int
3557lspo_object(lua_State *L)
3558{
3559 static object zeroobject = {
3560 { 0 }, /* Str_or_len name */
3561 0, /* corpsenm */
3562 0, 0, /* id, spe */
3563 0, /* coord */
3564 0, 0, /* coordxy x,y */
3565 0, 0, /* class, containment */
3566 0, /* curse_state */
3567 0, /* quan */
3568 0, /* buried */
3569 0, /* lit */
3570 0, 0, 0, 0, 0, /* eroded, locked, trapped, tknown, recharged */
3571 0, 0, 0, 0, /* invis, greased, broken, achievement */
3572 };
3573#if 0
3574 int nparams = 0;
3575#endif
3576 long quancnt;
3577 object tmpobj;
3578 lua_Integer ox = -1, oy = -1;
3579 int argc = lua_gettop(L);
3580 int maybe_contents = 0;
3581 struct obj *otmp = NULL;
3582
3583 create_des_coder();
3584
3585 tmpobj = zeroobject;
3586 tmpobj.name.str = (char *) 0;
3587 tmpobj.spe = -127;
3588 tmpobj.quan = -1;
3589 tmpobj.trapped = -1;
3590 tmpobj.tknown = -1;
3591 tmpobj.locked = -1;
3592 tmpobj.corpsenm = NON_PM;
3593
3594 if (argc == 1 && lua_type(L, 1) == LUA_TSTRING) {
3595 const char *paramstr = luaL_checkstring(L, 1);
3596
3597 if (strlen(paramstr) == 1) {
3598 tmpobj.class = *paramstr;
3599 tmpobj.id = STRANGE_OBJECT;
3600 } else {
3601 tmpobj.class = -1;
3602 tmpobj.id = find_objtype(L, paramstr, -1);
3603 }
3604 } else if (argc == 2 && lua_type(L, 1) == LUA_TSTRING
3605 && lua_type(L, 2) == LUA_TTABLE) {
3606 const char *paramstr = luaL_checkstring(L, 1);
3607
3608 (void) get_coord(L, 2, &ox, &oy);
3609
3610 if (strlen(paramstr) == 1) {
3611 tmpobj.class = *paramstr;
3612 tmpobj.id = STRANGE_OBJECT;
3613 } else {

Callers

nothing calls this directly

Calls 15

create_des_coderFunction · 0.85
find_objtypeFunction · 0.85
get_coordFunction · 0.85
lcheck_param_tableFunction · 0.85
get_table_int_or_randomFunction · 0.85
get_table_bucFunction · 0.85
get_table_str_optFunction · 0.85
get_table_boolean_optFunction · 0.85
get_table_int_optFunction · 0.85
get_table_xy_or_coordFunction · 0.85
get_table_objtypeFunction · 0.85
get_table_objclassFunction · 0.85

Tested by

no test coverage detected