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

Function l_obj_at

src/nhlobj.c:388–407  ·  view source on GitHub ↗

Get the topmost object on the map at x,y */ local o = obj.at(x, y); */

Source from the content-addressed store, hash-verified

386/* Get the topmost object on the map at x,y */
387/* local o = obj.at(x, y); */
388staticfn int
389l_obj_at(lua_State *L)
390{
391 int argc = lua_gettop(L);
392
393 if (argc == 2) {
394 coordxy x, y;
395
396 x = (coordxy) luaL_checkinteger(L, 1);
397 y = (coordxy) luaL_checkinteger(L, 2);
398 cvt_to_abscoord(&x, &y);
399
400 lua_pop(L, 2);
401 (void) l_obj_push(L, svl.level.objects[x][y]);
402 return 1;
403 } else
404 nhl_error(L, "l_obj_at: Wrong args");
405 /*NOTREACHED*/
406 return 0;
407}
408
409/* Place an object on the map at (x,y).
410 local o = obj.new("rock");

Callers

nothing calls this directly

Calls 3

cvt_to_abscoordFunction · 0.85
l_obj_pushFunction · 0.85
nhl_errorFunction · 0.85

Tested by

no test coverage detected