diff --git a/src/scripting/lua_kernel_base.cpp b/src/scripting/lua_kernel_base.cpp index 23847210655d..2af30827476a 100644 --- a/src/scripting/lua_kernel_base.cpp +++ b/src/scripting/lua_kernel_base.cpp @@ -546,6 +546,7 @@ lua_kernel_base::lua_kernel_base() { "rotate_right_around_center", &lua_map_location::intf_rotate_right_around_center }, { "are_hexes_adjacent", &lua_map_location::intf_tiles_adjacent }, { "get_adjacent_hexes", &lua_map_location::intf_get_adjacent_tiles }, + { "get_hexes_in_radius", &lua_map_location::intf_get_tiles_in_radius }, { "distance_between", &lua_map_location::intf_distance_between }, { "get_in_basis_N_NE", &lua_map_location::intf_get_in_basis_N_NE }, { "get_relative_dir", &lua_map_location::intf_get_relative_dir }, diff --git a/src/scripting/lua_map_location_ops.cpp b/src/scripting/lua_map_location_ops.cpp index 82cee50c3cb3..7b1af0f60e00 100644 --- a/src/scripting/lua_map_location_ops.cpp +++ b/src/scripting/lua_map_location_ops.cpp @@ -14,8 +14,10 @@ #include "scripting/lua_map_location_ops.hpp" #include "scripting/lua_common.hpp" +#include "scripting/push_check.hpp" #include "map/location.hpp" +#include "pathutils.hpp" #include #include @@ -87,7 +89,7 @@ int intf_vector_diff(lua_State* L) { map_location l1, l2; if(!luaW_tolocation(L, 1, l1) || !luaW_tolocation(L, 2, l2)) { - lua_pushstring(L, "vector_sum: requires two locations"); + lua_pushstring(L, "vector_diff: requires two locations"); return lua_error(L); } @@ -137,7 +139,7 @@ int intf_tiles_adjacent(lua_State* L) { map_location l1, l2; if(!luaW_tolocation(L, 1, l1) || !luaW_tolocation(L, 2, l2)) { - lua_pushstring(L, "vector_sum: requires two locations"); + lua_pushstring(L, "tiles_adjacent: requires two locations"); return lua_error(L); } @@ -164,6 +166,26 @@ int intf_get_adjacent_tiles(lua_State* L) return 6; } +/** + * Expose map_location get_tiles_in_radius + * - Arg 1: A location + * - Ret: The locations + */ +int intf_get_tiles_in_radius(lua_State* L) +{ + map_location l1; + if(!luaW_tolocation(L, 1, l1)) { + return luaL_argerror(L, 1, "expected a location"); + } + int radius = luaL_checkinteger(L, 2); + + std::vector locs; + get_tiles_in_radius(l1, radius, locs); + lua_push(L, locs); + + return 1; +} + /** * Expose map_location distance_between * - Args 1, 2: Two locations diff --git a/src/scripting/lua_map_location_ops.hpp b/src/scripting/lua_map_location_ops.hpp index 6b9039f3e8cc..c8dd64d40e6f 100644 --- a/src/scripting/lua_map_location_ops.hpp +++ b/src/scripting/lua_map_location_ops.hpp @@ -30,6 +30,7 @@ int intf_vector_negation(lua_State*); int intf_rotate_right_around_center(lua_State*); int intf_tiles_adjacent(lua_State*); int intf_get_adjacent_tiles(lua_State*); +int intf_get_tiles_in_radius(lua_State*); int intf_distance_between(lua_State*); int intf_get_in_basis_N_NE(lua_State*); int intf_get_relative_dir(lua_State*);