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); */
| 588 | /* TODO: selection.randline(x1,y1, x2,y2, roughness); */ |
| 589 | /* TODO: selection.randline({x1,y1}, {x2,y2}, roughness); */ |
| 590 | staticfn int |
| 591 | l_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"); */ |
nothing calls this directly
no test coverage detected