| 244 | local o = obj.new("rock"); |
| 245 | local otbl = o:totable(); */ |
| 246 | staticfn int |
| 247 | l_obj_to_table(lua_State *L) |
| 248 | { |
| 249 | struct _lua_obj *lo = l_obj_check(L, 1); |
| 250 | struct obj *obj = lo->obj; |
| 251 | |
| 252 | lua_newtable(L); |
| 253 | |
| 254 | if (!obj || obj->where == OBJ_LUAFREE) { |
| 255 | nhl_add_table_entry_int(L, "NO_OBJ", 1); |
| 256 | return 1; |
| 257 | } |
| 258 | |
| 259 | nhl_add_table_entry_int(L, "has_contents", Has_contents(obj)); |
| 260 | nhl_add_table_entry_int(L, "is_container", Is_container(obj)); |
| 261 | nhl_add_table_entry_int(L, "o_id", obj->o_id); |
| 262 | nhl_add_table_entry_int(L, "ox", obj->ox); |
| 263 | nhl_add_table_entry_int(L, "oy", obj->oy); |
| 264 | nhl_add_table_entry_int(L, "otyp", obj->otyp); |
| 265 | if (OBJ_NAME(objects[obj->otyp])) |
| 266 | nhl_add_table_entry_str(L, "otyp_name", OBJ_NAME(objects[obj->otyp])); |
| 267 | if (OBJ_DESCR(objects[obj->otyp])) |
| 268 | nhl_add_table_entry_str(L, "otyp_descr", |
| 269 | OBJ_DESCR(objects[obj->otyp])); |
| 270 | nhl_add_table_entry_int(L, "owt", obj->owt); |
| 271 | nhl_add_table_entry_int(L, "quan", obj->quan); |
| 272 | nhl_add_table_entry_int(L, "spe", obj->spe); |
| 273 | |
| 274 | if (obj->otyp == STATUE) |
| 275 | nhl_add_table_entry_int(L, "historic", |
| 276 | (obj->spe & CORPSTAT_HISTORIC) != 0); |
| 277 | if (obj->otyp == CORPSE || obj->otyp == STATUE) { |
| 278 | nhl_add_table_entry_int(L, "male", |
| 279 | (obj->spe & CORPSTAT_MALE) != 0); |
| 280 | nhl_add_table_entry_int(L, "female", |
| 281 | (obj->spe & CORPSTAT_FEMALE) != 0); |
| 282 | } |
| 283 | |
| 284 | nhl_add_table_entry_char(L, "oclass", |
| 285 | def_oc_syms[(uchar) obj->oclass].sym); |
| 286 | nhl_add_table_entry_char(L, "invlet", obj->invlet); |
| 287 | /* TODO: nhl_add_table_entry_char(L, "oartifact", obj->oartifact);*/ |
| 288 | nhl_add_table_entry_int(L, "where", obj->where); |
| 289 | /* TODO: nhl_add_table_entry_int(L, "timed", obj->timed); */ |
| 290 | nhl_add_table_entry_int(L, "cursed", obj->cursed); |
| 291 | nhl_add_table_entry_int(L, "blessed", obj->blessed); |
| 292 | nhl_add_table_entry_int(L, "unpaid", obj->unpaid); |
| 293 | nhl_add_table_entry_int(L, "no_charge", obj->no_charge); |
| 294 | nhl_add_table_entry_int(L, "known", obj->known); |
| 295 | nhl_add_table_entry_int(L, "dknown", obj->dknown); |
| 296 | nhl_add_table_entry_int(L, "bknown", obj->bknown); |
| 297 | nhl_add_table_entry_int(L, "rknown", obj->rknown); |
| 298 | nhl_add_table_entry_int(L, "tknown", obj->tknown); |
| 299 | if (obj->oclass == POTION_CLASS) |
| 300 | nhl_add_table_entry_int(L, "odiluted", obj->odiluted); |
| 301 | else |
| 302 | nhl_add_table_entry_int(L, "oeroded", obj->oeroded); |
| 303 | nhl_add_table_entry_int(L, "oeroded2", obj->oeroded2); |
nothing calls this directly
no test coverage detected