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

Function l_selection_randline

src/nhlsel.c:590–626  ·  view source on GitHub ↗

local s = selection.randline(sel, x1,y1, x2,y2, roughness); */ local s = selection.randline(x1,y1, x2,y2, roughness); */ TODO: selection.randline(x1,y1, x2,y2, roughness); */ TODO: selection.randline({x1,y1}, {x2,y2}, roughness); */

Source from the content-addressed store, hash-verified

588/* TODO: selection.randline(x1,y1, x2,y2, roughness); */
589/* TODO: selection.randline({x1,y1}, {x2,y2}, roughness); */
590staticfn int
591l_selection_randline(lua_State *L)
592{
593 int argc = lua_gettop(L);
594 struct selectionvar *sel;
595 coordxy x1 = 0, y1 = 0, x2 = 0, y2 = 0;
596 int roughness = 7;
597
598 if (argc == 6) {
599 (void) l_selection_check(L, 1);
600 x1 = (coordxy) luaL_checkinteger(L, 2);
601 y1 = (coordxy) luaL_checkinteger(L, 3);
602 x2 = (coordxy) luaL_checkinteger(L, 4);
603 y2 = (coordxy) luaL_checkinteger(L, 5);
604 roughness = (int) luaL_checkinteger(L, 6);
605 lua_pop(L, 5);
606 } else if (argc == 5 && lua_type(L, 1) == LUA_TNUMBER) {
607 x1 = (coordxy) luaL_checkinteger(L, 1);
608 y1 = (coordxy) luaL_checkinteger(L, 2);
609 x2 = (coordxy) luaL_checkinteger(L, 3);
610 y2 = (coordxy) luaL_checkinteger(L, 4);
611 roughness = (int) luaL_checkinteger(L, 5);
612 lua_pop(L, 5);
613 (void) l_selection_new(L);
614 (void) l_selection_check(L, 1);
615 }
616
617 get_location_coord(&x1, &y1, ANY_LOC, gc.coder ? gc.coder->croom : NULL,
618 SP_COORD_PACK(x1, y1));
619 get_location_coord(&x2, &y2, ANY_LOC, gc.coder ? gc.coder->croom : NULL,
620 SP_COORD_PACK(x2, y2));
621
622 (void) l_selection_clone(L);
623 sel = l_selection_check(L, 2);
624 selection_do_randline(x1, y1, x2, y2, roughness, 12, sel);
625 return 1;
626}
627
628/* local s = selection.grow(sel); */
629/* local s = selection.grow(sel, "north"); */

Callers

nothing calls this directly

Calls 5

l_selection_checkFunction · 0.85
l_selection_newFunction · 0.85
get_location_coordFunction · 0.85
l_selection_cloneFunction · 0.85
selection_do_randlineFunction · 0.85

Tested by

no test coverage detected