summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-10-19 23:15:11 +0200
committerRobert Vollmert <rvollmert@gmx.net>2009-10-19 23:15:11 +0200
commit49a01f5ae457bb601165eb89f6437d392a036eae (patch)
treec659c35fcd93eb27ea7a9116dc8b683579464342 /crawl-ref/source
parent99551ab330ffd7037891fffc159708298159a432 (diff)
downloadcrawl-ref-49a01f5ae457bb601165eb89f6437d392a036eae.tar.gz
crawl-ref-49a01f5ae457bb601165eb89f6437d392a036eae.zip
Split you_lib out from dlua.cc.
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/dlua.cc49
-rw-r--r--crawl-ref/source/l_libs.h1
-rw-r--r--crawl-ref/source/l_you.cc56
-rw-r--r--crawl-ref/source/makefile.obj1
4 files changed, 58 insertions, 49 deletions
diff --git a/crawl-ref/source/dlua.cc b/crawl-ref/source/dlua.cc
index d9ce189b36..9af08e3829 100644
--- a/crawl-ref/source/dlua.cc
+++ b/crawl-ref/source/dlua.cc
@@ -321,55 +321,6 @@ std::string dlua_chunk::get_chunk_prefix(const std::string &sorig) const
return rewrite_chunk_prefix(sorig, true);
}
-LUARET1(you_can_hear_pos, boolean,
- player_can_hear(coord_def(luaL_checkint(ls,1), luaL_checkint(ls, 2))))
-LUARET1(you_x_pos, number, you.pos().x)
-LUARET1(you_y_pos, number, you.pos().y)
-LUARET2(you_pos, number, you.pos().x, you.pos().y)
-
-// see_cell should not be exposed to user scripts. The game should
-// never disclose grid coordinates to the player. Therefore we load it
-// only into the core Lua interpreter (dlua), never into the user
-// script interpreter (clua).
-LUARET1(you_see_cell, boolean,
- see_cell(luaL_checkint(ls, 1), luaL_checkint(ls, 2)))
-LUARET1(you_see_cell_no_trans, boolean,
- see_cell_no_trans(luaL_checkint(ls, 1), luaL_checkint(ls, 2)))
-
-LUAFN(you_moveto)
-{
- const coord_def place(luaL_checkint(ls, 1), luaL_checkint(ls, 2));
- ASSERT(map_bounds(place));
- you.moveto(place);
- return (0);
-}
-
-LUAFN(you_random_teleport)
-{
- you_teleport_now(false, false);
- return (0);
-}
-
-LUAFN(you_losight)
-{
- calc_show_los();
- return (0);
-}
-
-static const struct luaL_reg you_lib[] =
-{
- { "hear_pos", you_can_hear_pos },
- { "x_pos", you_x_pos },
- { "y_pos", you_y_pos },
- { "pos", you_pos },
- { "moveto", you_moveto },
- { "see_cell", you_see_cell },
- { "see_cell_no_trans", you_see_cell_no_trans },
- { "random_teleport", you_random_teleport },
- { "losight", you_losight },
- { NULL, NULL }
-};
-
static int dgnevent_type(lua_State *ls)
{
DEVENT(ls, 1, dev);
diff --git a/crawl-ref/source/l_libs.h b/crawl-ref/source/l_libs.h
index a0e926d177..cc0462e5e1 100644
--- a/crawl-ref/source/l_libs.h
+++ b/crawl-ref/source/l_libs.h
@@ -4,6 +4,7 @@ extern const struct luaL_reg crawl_lib[];
extern const struct luaL_reg dgn_lib[];
extern const struct luaL_reg file_lib[];
extern const struct luaL_reg los_lib[];
+extern const struct luaL_reg you_lib[];
void luaopen_ray(lua_State *ls);
diff --git a/crawl-ref/source/l_you.cc b/crawl-ref/source/l_you.cc
new file mode 100644
index 0000000000..4ecf0ef0cc
--- /dev/null
+++ b/crawl-ref/source/l_you.cc
@@ -0,0 +1,56 @@
+#include "AppHdr.h"
+
+#include "dlua.h"
+#include "l_libs.h"
+
+#include "los.h"
+#include "spells3.h"
+
+LUARET1(you_can_hear_pos, boolean,
+ player_can_hear(coord_def(luaL_checkint(ls,1), luaL_checkint(ls, 2))))
+LUARET1(you_x_pos, number, you.pos().x)
+LUARET1(you_y_pos, number, you.pos().y)
+LUARET2(you_pos, number, you.pos().x, you.pos().y)
+
+// see_cell should not be exposed to user scripts. The game should
+// never disclose grid coordinates to the player. Therefore we load it
+// only into the core Lua interpreter (dlua), never into the user
+// script interpreter (clua).
+LUARET1(you_see_cell, boolean,
+ see_cell(luaL_checkint(ls, 1), luaL_checkint(ls, 2)))
+LUARET1(you_see_cell_no_trans, boolean,
+ see_cell_no_trans(luaL_checkint(ls, 1), luaL_checkint(ls, 2)))
+
+LUAFN(you_moveto)
+{
+ const coord_def place(luaL_checkint(ls, 1), luaL_checkint(ls, 2));
+ ASSERT(map_bounds(place));
+ you.moveto(place);
+ return (0);
+}
+
+LUAFN(you_random_teleport)
+{
+ you_teleport_now(false, false);
+ return (0);
+}
+
+LUAFN(you_losight)
+{
+ calc_show_los();
+ return (0);
+}
+
+const struct luaL_reg you_lib[] =
+{
+{ "hear_pos", you_can_hear_pos },
+{ "x_pos", you_x_pos },
+{ "y_pos", you_y_pos },
+{ "pos", you_pos },
+{ "moveto", you_moveto },
+{ "see_cell", you_see_cell },
+{ "see_cell_no_trans", you_see_cell_no_trans },
+{ "random_teleport", you_random_teleport },
+{ "losight", you_losight },
+{ NULL, NULL }
+};
diff --git a/crawl-ref/source/makefile.obj b/crawl-ref/source/makefile.obj
index 892a6db740..daecc97926 100644
--- a/crawl-ref/source/makefile.obj
+++ b/crawl-ref/source/makefile.obj
@@ -42,6 +42,7 @@ l_crawl.o \
l_dgn.o \
l_file.o \
l_los.o \
+l_you.o \
los.o \
losparam.o \
macro.o \