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

Function l_selection_getpoint

src/nhlsel.c:223–252  ·  view source on GitHub ↗

local value = selection.get(sel, x, y); */

Source from the content-addressed store, hash-verified

221
222/* local value = selection.get(sel, x, y); */
223staticfn int
224l_selection_getpoint(lua_State *L)
225{
226 struct selectionvar *sel = l_selection_check(L, 1);
227 coordxy x, y;
228 lua_Integer ix, iy;
229 int val;
230 long crd;
231
232 lua_remove(L, 1); /* sel */
233 if (!nhl_get_xy_params(L, &ix, &iy)) {
234 nhl_error(L, "l_selection_getpoint: Incorrect params");
235 /*NOTREACHED*/
236 return 0;
237 }
238 x = (coordxy) ix;
239 y = (coordxy) iy;
240
241 if (x == -1 && y == -1)
242 crd = SP_COORD_PACK_RANDOM(0);
243 else
244 crd = SP_COORD_PACK(x,y);
245 get_location_coord(&x, &y, ANY_LOC,
246 gc.coder ? gc.coder->croom : NULL, crd);
247
248 val = selection_getpoint(x, y, sel);
249 lua_settop(L, 0);
250 lua_pushnumber(L, val);
251 return 1;
252}
253
254RESTORE_WARNING_UNREACHABLE_CODE
255

Callers

nothing calls this directly

Calls 5

l_selection_checkFunction · 0.85
nhl_get_xy_paramsFunction · 0.85
nhl_errorFunction · 0.85
get_location_coordFunction · 0.85
selection_getpointFunction · 0.85

Tested by

no test coverage detected