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

Function l_selection_circle

src/nhlsel.c:761–803  ·  view source on GitHub ↗

local s = selection.circle(x,y, radius); */ local s = selection.circle(x, y, radius, filled); */ local s = selection.circle(sel, x, y, radius); */ local s = selection.circle(sel, x, y, radius, filled); */

Source from the content-addressed store, hash-verified

759/* local s = selection.circle(sel, x, y, radius); */
760/* local s = selection.circle(sel, x, y, radius, filled); */
761staticfn int
762l_selection_circle(lua_State *L)
763{
764 int argc = lua_gettop(L);
765 struct selectionvar *sel = (struct selectionvar *) 0;
766 coordxy x = 0, y = 0;
767 int r = 0, filled = 0;
768
769 if (argc == 3) {
770 x = (coordxy) luaL_checkinteger(L, 1);
771 y = (coordxy) luaL_checkinteger(L, 2);
772 r = (int) luaL_checkinteger(L, 3);
773 lua_pop(L, 3);
774 (void) l_selection_new(L);
775 sel = l_selection_check(L, 1);
776 filled = 0;
777 } else if (argc == 4 && lua_type(L, 1) == LUA_TNUMBER) {
778 x = (coordxy) luaL_checkinteger(L, 1);
779 y = (coordxy) luaL_checkinteger(L, 2);
780 r = (int) luaL_checkinteger(L, 3);
781 filled = (int) luaL_checkinteger(L, 4); /* TODO: boolean*/
782 lua_pop(L, 4);
783 (void) l_selection_new(L);
784 sel = l_selection_check(L, 1);
785 } else if (argc == 4 || argc == 5) {
786 sel = l_selection_check(L, 1);
787 x = (coordxy) luaL_checkinteger(L, 2);
788 y = (coordxy) luaL_checkinteger(L, 3);
789 r = (int) luaL_checkinteger(L, 4);
790 filled = (int) luaL_optinteger(L, 5, 0); /* TODO: boolean */
791 } else {
792 nhl_error(L, "wrong parameters");
793 /*NOTREACHED*/
794 }
795
796 get_location_coord(&x, &y, ANY_LOC, gc.coder ? gc.coder->croom : NULL,
797 SP_COORD_PACK(x, y));
798
799 selection_do_ellipse(sel, x, y, r, r, !filled);
800
801 lua_settop(L, 1);
802 return 1;
803}
804
805/* local s = selection.ellipse(x, y, radius1, radius2); */
806/* local s = selection.ellipse(x, y, radius1, radius2, filled); */

Callers

nothing calls this directly

Calls 5

l_selection_newFunction · 0.85
l_selection_checkFunction · 0.85
nhl_errorFunction · 0.85
get_location_coordFunction · 0.85
selection_do_ellipseFunction · 0.85

Tested by

no test coverage detected