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} }); */
| 3554 | /* object({ id = "boulder", x = 03, y = 12}); */ |
| 3555 | /* object({ id = "boulder", coord = {03,12} }); */ |
| 3556 | int |
| 3557 | lspo_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 { |
nothing calls this directly
no test coverage detected