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

Function nhl_int_to_obj_name

src/nhlua.c:1191–1212  ·  view source on GitHub ↗

convert integer to object type name and class */ local oname,oclass = int_to_objname(25); */

Source from the content-addressed store, hash-verified

1189/* convert integer to object type name and class */
1190/* local oname,oclass = int_to_objname(25); */
1191staticfn int
1192nhl_int_to_obj_name(lua_State *L)
1193{
1194 int argc = lua_gettop(L);
1195
1196 if (argc == 1) {
1197 char buf[8];
1198 lua_Integer i = luaL_checkinteger(L, 1);
1199
1200 if (i >= 0 && i < NUM_OBJECTS && OBJ_NAME(objects[i])) {
1201 lua_pushstring(L, OBJ_NAME(objects[i]));
1202 buf[0] = def_oc_syms[(int)objects[i].oc_class].sym;
1203 buf[1] = '\0';
1204 lua_pushstring(L, buf);
1205 } else {
1206 lua_pushstring(L, "");
1207 lua_pushstring(L, "");
1208 }
1209 } else
1210 nhl_error(L, "Expected an integer parameter");
1211 return 2;
1212}
1213
1214DISABLE_WARNING_UNREACHABLE_CODE
1215/* because nhl_error() does not return */

Callers

nothing calls this directly

Calls 1

nhl_errorFunction · 0.85

Tested by

no test coverage detected