diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2009-11-12 12:08:13 +0100 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2009-11-12 12:27:53 +0100 |
commit | 7f502e207784d2c33ab38079dadfa298ab9fafc6 (patch) | |
tree | 64455ef722ff0a7179bd7c8b7b0bcfefd9a76a33 /crawl-ref/source | |
parent | d728a1cd0de075594762733936732d3d7f91f410 (diff) | |
download | crawl-ref-7f502e207784d2c33ab38079dadfa298ab9fafc6.tar.gz crawl-ref-7f502e207784d2c33ab38079dadfa298ab9fafc6.zip |
set_exclude/del_exclude lua bindings.
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/clua.cc | 1 | ||||
-rw-r--r-- | crawl-ref/source/l_defs.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/l_libs.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/l_travel.cc | 54 | ||||
-rw-r--r-- | crawl-ref/source/makefile.obj | 1 |
5 files changed, 58 insertions, 0 deletions
diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc index 64fd63b768..4f25a2d362 100644 --- a/crawl-ref/source/clua.cc +++ b/crawl-ref/source/clua.cc @@ -622,6 +622,7 @@ void CLua::init_lua() cluaopen_file(_state); cluaopen_moninf(_state); cluaopen_options(_state); + cluaopen_travel(_state); cluaopen_view(_state); cluaopen_globals(_state); diff --git a/crawl-ref/source/l_defs.h b/crawl-ref/source/l_defs.h index 641af4a117..8d0974a918 100644 --- a/crawl-ref/source/l_defs.h +++ b/crawl-ref/source/l_defs.h @@ -14,6 +14,7 @@ const char *dungeon_feature_name(dungeon_feature_type feat); std::string dgn_set_default_depth(const std::string &s); void dgn_reset_default_depth(); bool in_show_bounds(const coord_def &c); +coord_def player2grid(const coord_def &p); #endif diff --git a/crawl-ref/source/l_libs.h b/crawl-ref/source/l_libs.h index ecbecd12ba..a97eb7dc75 100644 --- a/crawl-ref/source/l_libs.h +++ b/crawl-ref/source/l_libs.h @@ -19,6 +19,7 @@ void cluaopen_item(lua_State *ls); void cluaopen_kills(lua_State *ls); // defined in kills.cc void cluaopen_moninf(lua_State *ls); void cluaopen_options(lua_State *ls); +void cluaopen_travel(lua_State *ls); void cluaopen_view(lua_State *ls); void cluaopen_you(lua_State *ls); diff --git a/crawl-ref/source/l_travel.cc b/crawl-ref/source/l_travel.cc new file mode 100644 index 0000000000..8c32d65812 --- /dev/null +++ b/crawl-ref/source/l_travel.cc @@ -0,0 +1,54 @@ +/* + * File: l_travel.cc + * Summary: Travel and exclusions. + */ + +#include "AppHdr.h" + +#include "l_libs.h" +#include "l_defs.h" + +#include "cluautil.h" +#include "coord.h" +#include "exclude.h" +#include "player.h" + +LUAFN(l_set_exclude) +{ + coord_def s; + s.x = luaL_checkint(ls, 1); + s.y = luaL_checkint(ls, 2); + const coord_def p = player2grid(s); + if (!in_bounds(p)) + return (0); + int r = LOS_MAX_RADIUS; + if (lua_gettop(ls) > 2) + r = luaL_checkint(ls, 3); + set_exclude(p, r); + return (0); +} + +LUAFN(l_del_exclude) +{ + coord_def s; + s.x = luaL_checkint(ls, 1); + s.y = luaL_checkint(ls, 2); + const coord_def p = player2grid(s); + if (!in_bounds(p)) + return (0); + del_exclude(p); + return (0); +} + +static const struct luaL_reg travel_lib[] = +{ + { "set_exclude", l_set_exclude }, + { "del_exclude", l_del_exclude }, + + { NULL, NULL } +}; + +void cluaopen_travel(lua_State *ls) +{ + luaL_openlib(ls, "travel", travel_lib, 0); +} diff --git a/crawl-ref/source/makefile.obj b/crawl-ref/source/makefile.obj index b8728e6839..03fe8f2bd3 100644 --- a/crawl-ref/source/makefile.obj +++ b/crawl-ref/source/makefile.obj @@ -79,6 +79,7 @@ l_mapmrk.o \ l_moninf.o \ l_mons.o \ l_option.o \ +l_travel.o \ l_view.o \ l_you.o \ lev-pand.o \ |