39 return luaL_argerror(L, 1,
"get_direction: first argument(S) must be a location");
41 int nargs = lua_gettop(L);
43 luaL_error(L,
"get_direction: not missing direction argument");
49 n = luaL_checkinteger(L, -1);
54 if (lua_isstring(L, -1)) {
58 std::string
msg(
"get_direction: second argument should be a direction string, instead found a ");
59 msg += lua_typename(L, lua_type(L, -1));
60 return luaL_argerror(L, -1,
msg.c_str());
75 lua_pushstring(L,
"vector_sum: requires two locations");
90 lua_pushstring(L,
"vector_diff: requires two locations");
107 return luaL_argerror(L, 1,
"expected a location");
119 int k = luaL_checkinteger(L, -1);
123 lua_pushstring(L,
"rotate_right_around_center: requires two locations");
140 lua_pushstring(L,
"tiles_adjacent: requires two locations");
157 return luaL_argerror(L, 1,
"expected a location");
176 return luaL_argerror(L, 1,
"expected a location");
178 int radius = luaL_checkinteger(L, 2);
180 std::vector<map_location> locs;
196 lua_pushstring(L,
"distance_between: requires two locations");
211 return luaL_argerror(L, 1,
"expected a location");
215 lua_pushinteger(L, r.first);
216 lua_pushinteger(L, r.second);
229 lua_pushstring(L,
"get_relative_dir: requires two locations");
234 lua_pushlstring(L, dir.c_str(), dir.length());
void get_adjacent_tiles(const map_location &a, map_location *res)
Function which, given a location, will place all adjacent locations in res.
std::size_t distance_between(const map_location &a, const map_location &b)
Function which gives the number of hexes between two tiles (i.e.
bool tiles_adjacent(const map_location &a, const map_location &b)
Function which tells if two locations are adjacent.
void luaW_pushlocation(lua_State *L, const map_location &ml)
Converts a map location object to a Lua table pushed at the top of the stack.
bool luaW_tolocation(lua_State *L, int index, map_location &loc)
Converts an optional table or pair of integers to a map location object.
int intf_get_relative_dir(lua_State *L)
Expose map_location get_relative_dir.
int intf_vector_negation(lua_State *L)
Expose map_location::vector_negation to lua.
int intf_distance_between(lua_State *L)
Expose map_location distance_between.
int intf_get_in_basis_N_NE(lua_State *L)
Expose map_location get_in_basis_N_NE.
int intf_tiles_adjacent(lua_State *L)
Expose map_location tiles_adjacent.
int intf_vector_diff(lua_State *L)
Expose map_location::vector_difference to lua.
int intf_vector_sum(lua_State *L)
Expose map_location::vector_sum to lua.
int intf_rotate_right_around_center(lua_State *L)
Expose map_location::rotate_right_around_center to lua.
int intf_get_tiles_in_radius(lua_State *L)
Expose map_location get_tiles_in_radius.
int intf_get_adjacent_tiles(lua_State *L)
Expose map_location get_adjacent_tiles.
int intf_get_direction(lua_State *L)
Expose map_location::get_direction function to lua Arg 1: a location Arg 2: a direction Arg 3: (optio...
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
void get_tiles_in_radius(const map_location ¢er, const int radius, std::vector< map_location > &result)
Function that will add to result all locations within radius tiles of center (excluding center itself...
void lua_push(lua_State *L, const T &val)
Encapsulates the map of the game.
map_location & vector_sum_assign(const map_location &a)
map_location & vector_difference_assign(const map_location &a)
static DIRECTION parse_direction(const std::string &str)
map_location vector_negation() const
std::pair< int, int > get_in_basis_N_NE() const
DIRECTION
Valid directions which can be moved in our hexagonal world.
map_location get_direction(DIRECTION dir, unsigned int n=1u) const
DIRECTION get_relative_dir(const map_location &loc, map_location::RELATIVE_DIR_MODE mode) const
map_location rotate_right_around_center(const map_location ¢er, int k) const
static std::string write_direction(DIRECTION dir)
static map_location::DIRECTION n