Unify some exported lua script params
This commit is contained in:
94
src/nhlsel.c
94
src/nhlsel.c
@@ -13,6 +13,8 @@ static int FDECL(l_selection_setpoint, (lua_State *));
|
|||||||
static int FDECL(l_selection_not, (lua_State *));
|
static int FDECL(l_selection_not, (lua_State *));
|
||||||
static int FDECL(l_selection_filter_percent, (lua_State *));
|
static int FDECL(l_selection_filter_percent, (lua_State *));
|
||||||
static int FDECL(l_selection_rndcoord, (lua_State *));
|
static int FDECL(l_selection_rndcoord, (lua_State *));
|
||||||
|
static boolean FDECL(params_sel_2coords, (lua_State *, struct selectionvar *,
|
||||||
|
schar *, schar *, schar *, schar *));
|
||||||
static int FDECL(l_selection_line, (lua_State *));
|
static int FDECL(l_selection_line, (lua_State *));
|
||||||
static int FDECL(l_selection_randline, (lua_State *));
|
static int FDECL(l_selection_randline, (lua_State *));
|
||||||
static int FDECL(l_selection_rect, (lua_State *));
|
static int FDECL(l_selection_rect, (lua_State *));
|
||||||
@@ -312,6 +314,39 @@ lua_State *L;
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* function(selection, x1,y1, x2,y2) */
|
||||||
|
/* selection:function(x1,y1, x2,y2) */
|
||||||
|
static boolean
|
||||||
|
params_sel_2coords(L, sel, x1,y1, x2,y2)
|
||||||
|
lua_State *L;
|
||||||
|
struct selectionvar *sel;
|
||||||
|
schar *x1, *y1, *x2, *y2;
|
||||||
|
{
|
||||||
|
int argc = lua_gettop(L);
|
||||||
|
|
||||||
|
if (argc == 4) {
|
||||||
|
(void) l_selection_new(L);
|
||||||
|
*x1 = (schar) luaL_checkinteger(L, 1);
|
||||||
|
*y1 = (schar) luaL_checkinteger(L, 2);
|
||||||
|
*x2 = (schar) luaL_checkinteger(L, 3);
|
||||||
|
*y2 = (schar) luaL_checkinteger(L, 4);
|
||||||
|
sel = l_selection_check(L, 5);
|
||||||
|
lua_remove(L, 1);
|
||||||
|
lua_remove(L, 1);
|
||||||
|
lua_remove(L, 1);
|
||||||
|
lua_remove(L, 1);
|
||||||
|
return TRUE;
|
||||||
|
} else if (argc == 5) {
|
||||||
|
sel = l_selection_check(L, 1);
|
||||||
|
*x1 = (schar) luaL_checkinteger(L, 2);
|
||||||
|
*y1 = (schar) luaL_checkinteger(L, 3);
|
||||||
|
*x2 = (schar) luaL_checkinteger(L, 4);
|
||||||
|
*y2 = (schar) luaL_checkinteger(L, 5);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* local s = selection.line(sel, x1,y1, x2,y2); */
|
/* local s = selection.line(sel, x1,y1, x2,y2); */
|
||||||
/* local s = selection.line(x1,y1, x2,y2); */
|
/* local s = selection.line(x1,y1, x2,y2); */
|
||||||
/* s:line(x1,y1, x2,y2); */
|
/* s:line(x1,y1, x2,y2); */
|
||||||
@@ -319,30 +354,14 @@ static int
|
|||||||
l_selection_line(L)
|
l_selection_line(L)
|
||||||
lua_State *L;
|
lua_State *L;
|
||||||
{
|
{
|
||||||
int argc = lua_gettop(L);
|
|
||||||
struct selectionvar *sel;
|
struct selectionvar *sel;
|
||||||
schar x1;
|
schar x1;
|
||||||
schar y1;
|
schar y1;
|
||||||
schar x2;
|
schar x2;
|
||||||
schar y2;
|
schar y2;
|
||||||
|
|
||||||
if (argc == 4) {
|
if (!params_sel_2coords(L, sel, &x1, &y1, &x2, &y2)) {
|
||||||
(void) l_selection_new(L);
|
nhl_error(L, "selection.line: illegal arguments");
|
||||||
x1 = (schar) luaL_checkinteger(L, 1);
|
|
||||||
y1 = (schar) luaL_checkinteger(L, 2);
|
|
||||||
x2 = (schar) luaL_checkinteger(L, 3);
|
|
||||||
y2 = (schar) luaL_checkinteger(L, 4);
|
|
||||||
sel = l_selection_check(L, 5);
|
|
||||||
lua_remove(L, 1);
|
|
||||||
lua_remove(L, 1);
|
|
||||||
lua_remove(L, 1);
|
|
||||||
lua_remove(L, 1);
|
|
||||||
} else {
|
|
||||||
sel = l_selection_check(L, 1);
|
|
||||||
x1 = (schar) luaL_checkinteger(L, 2);
|
|
||||||
y1 = (schar) luaL_checkinteger(L, 3);
|
|
||||||
x2 = (schar) luaL_checkinteger(L, 4);
|
|
||||||
y2 = (schar) luaL_checkinteger(L, 5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_location_coord(&x1, &y1, ANY_LOC, g.coder ? g.coder->croom : NULL, SP_COORD_PACK(x1,y1));
|
get_location_coord(&x1, &y1, ANY_LOC, g.coder ? g.coder->croom : NULL, SP_COORD_PACK(x1,y1));
|
||||||
@@ -358,30 +377,14 @@ static int
|
|||||||
l_selection_rect(L)
|
l_selection_rect(L)
|
||||||
lua_State *L;
|
lua_State *L;
|
||||||
{
|
{
|
||||||
int argc = lua_gettop(L);
|
|
||||||
struct selectionvar *sel;
|
struct selectionvar *sel;
|
||||||
schar x1;
|
schar x1;
|
||||||
schar y1;
|
schar y1;
|
||||||
schar x2;
|
schar x2;
|
||||||
schar y2;
|
schar y2;
|
||||||
|
|
||||||
if (argc == 4) {
|
if (!params_sel_2coords(L, sel, &x1, &y1, &x2, &y2)) {
|
||||||
(void) l_selection_new(L);
|
nhl_error(L, "selection.rect: illegal arguments");
|
||||||
x1 = (schar) luaL_checkinteger(L, 1);
|
|
||||||
y1 = (schar) luaL_checkinteger(L, 2);
|
|
||||||
x2 = (schar) luaL_checkinteger(L, 3);
|
|
||||||
y2 = (schar) luaL_checkinteger(L, 4);
|
|
||||||
sel = l_selection_check(L, 5);
|
|
||||||
lua_remove(L, 1);
|
|
||||||
lua_remove(L, 1);
|
|
||||||
lua_remove(L, 1);
|
|
||||||
lua_remove(L, 1);
|
|
||||||
} else {
|
|
||||||
sel = l_selection_check(L, 1);
|
|
||||||
x1 = (schar) luaL_checkinteger(L, 2);
|
|
||||||
y1 = (schar) luaL_checkinteger(L, 3);
|
|
||||||
x2 = (schar) luaL_checkinteger(L, 4);
|
|
||||||
y2 = (schar) luaL_checkinteger(L, 5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_location_coord(&x1, &y1, ANY_LOC, g.coder ? g.coder->croom : NULL, SP_COORD_PACK(x1,y1));
|
get_location_coord(&x1, &y1, ANY_LOC, g.coder ? g.coder->croom : NULL, SP_COORD_PACK(x1,y1));
|
||||||
@@ -411,23 +414,8 @@ lua_State *L;
|
|||||||
schar x2;
|
schar x2;
|
||||||
schar y2;
|
schar y2;
|
||||||
|
|
||||||
if (argc == 4) {
|
if (!params_sel_2coords(L, sel, &x1, &y1, &x2, &y2)) {
|
||||||
(void) l_selection_new(L);
|
nhl_error(L, "selection.fillrect: illegal arguments");
|
||||||
x1 = (schar) luaL_checkinteger(L, 1);
|
|
||||||
y1 = (schar) luaL_checkinteger(L, 2);
|
|
||||||
x2 = (schar) luaL_checkinteger(L, 3);
|
|
||||||
y2 = (schar) luaL_checkinteger(L, 4);
|
|
||||||
sel = l_selection_check(L, 5);
|
|
||||||
lua_remove(L, 1);
|
|
||||||
lua_remove(L, 1);
|
|
||||||
lua_remove(L, 1);
|
|
||||||
lua_remove(L, 1);
|
|
||||||
} else {
|
|
||||||
sel = l_selection_check(L, 1);
|
|
||||||
x1 = (schar) luaL_checkinteger(L, 2);
|
|
||||||
y1 = (schar) luaL_checkinteger(L, 3);
|
|
||||||
x2 = (schar) luaL_checkinteger(L, 4);
|
|
||||||
y2 = (schar) luaL_checkinteger(L, 5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_location_coord(&x1, &y1, ANY_LOC, g.coder ? g.coder->croom : NULL, SP_COORD_PACK(x1,y1));
|
get_location_coord(&x1, &y1, ANY_LOC, g.coder ? g.coder->croom : NULL, SP_COORD_PACK(x1,y1));
|
||||||
|
|||||||
Reference in New Issue
Block a user