Apply the new ground_level method.
[crawl.git] / crawl-ref / source / l_travel.cc
blob875b357b2bae376009245fbb0a4891a90306425e
1 /*
2 * File: l_travel.cc
3 * Summary: Travel and exclusions.
4 */
6 #include "AppHdr.h"
8 #include "l_libs.h"
9 #include "l_defs.h"
11 #include "branch.h"
12 #include "cluautil.h"
13 #include "coord.h"
14 #include "exclude.h"
15 #include "player.h"
16 #include "travel.h"
18 LUAFN(l_set_exclude)
20 coord_def s;
21 s.x = luaL_checkint(ls, 1);
22 s.y = luaL_checkint(ls, 2);
23 const coord_def p = player2grid(s);
24 if (!in_bounds(p))
25 return (0);
26 int r = LOS_MAX_RADIUS;
27 if (lua_gettop(ls) > 2)
28 r = luaL_checkint(ls, 3);
29 set_exclude(p, r);
30 return (0);
33 LUAFN(l_del_exclude)
35 coord_def s;
36 s.x = luaL_checkint(ls, 1);
37 s.y = luaL_checkint(ls, 2);
38 const coord_def p = player2grid(s);
39 if (!in_bounds(p))
40 return (0);
41 del_exclude(p);
42 return (0);
45 LUAFN(l_feature_is_traversable)
47 const std::string &name = luaL_checkstring(ls, 1);
48 const dungeon_feature_type feat = dungeon_feature_by_name(name);
49 PLUARET(boolean, feat_is_traversable(feat));
52 LUAFN(l_find_deepest_explored)
54 const std::string &branch = luaL_checkstring(ls, 1);
55 const level_id lid(str_to_branch(branch), 1);
56 if (lid.branch == NUM_BRANCHES)
57 luaL_error(ls, "Bad branch name: '%s'", branch.c_str());
58 PLUARET(number, find_deepest_explored(lid).depth);
61 static const struct luaL_reg travel_lib[] =
63 { "set_exclude", l_set_exclude },
64 { "del_exclude", l_del_exclude },
65 { "feature_traversable", l_feature_is_traversable },
66 { "find_deepest_explored", l_find_deepest_explored },
68 { NULL, NULL }
71 void cluaopen_travel(lua_State *ls)
73 luaL_openlib(ls, "travel", travel_lib, 0);