Puts object inside another object. */ local box = obj.new("large chest"); box:addcontent(obj.new("rock")); */
| 111 | box:addcontent(obj.new("rock")); |
| 112 | */ |
| 113 | staticfn int |
| 114 | l_obj_add_to_container(lua_State *L) |
| 115 | { |
| 116 | struct _lua_obj *lobox = l_obj_check(L, 1); |
| 117 | struct _lua_obj *lo = l_obj_check(L, 2); |
| 118 | struct obj *otmp; |
| 119 | int refs; |
| 120 | |
| 121 | if (!lobj_is_ok(lo) || !lobj_is_ok(lobox)) |
| 122 | return 0; |
| 123 | |
| 124 | refs = lo->obj->lua_ref_cnt; |
| 125 | |
| 126 | obj_extract_self(lo->obj); |
| 127 | otmp = add_to_container(lobox->obj, lo->obj); |
| 128 | |
| 129 | /* was lo->obj merged? */ |
| 130 | if (otmp != lo->obj) { |
| 131 | lo->obj = otmp; |
| 132 | lo->obj->lua_ref_cnt += refs; |
| 133 | } |
| 134 | lobox->obj->owt = weight(lobox->obj); |
| 135 | |
| 136 | return 0; |
| 137 | } |
| 138 | |
| 139 | /* Put object into player's inventory */ |
| 140 | /* u.giveobj(obj.new("rock")); */ |
nothing calls this directly
no test coverage detected