diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-11-24 20:43:26 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-11-24 20:43:26 +0000 |
commit | 376669c4079cfc19380a15b7791f744d06fe0ed1 (patch) | |
tree | 51a7bba01b01c48dd5b6a6461a04303e2dab30a2 /crawl-ref/source/clua.cc | |
parent | b369e7edc13b4f3528ffcaa93dfc427281e70758 (diff) | |
download | crawl-ref-376669c4079cfc19380a15b7791f744d06fe0ed1.tar.gz crawl-ref-376669c4079cfc19380a15b7791f744d06fe0ed1.zip |
Add pillars to ziggurat, more utility functions for Lua to handle maps.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7591 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/clua.cc')
-rw-r--r-- | crawl-ref/source/clua.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc index fac00a74dd..ae30763ab3 100644 --- a/crawl-ref/source/clua.cc +++ b/crawl-ref/source/clua.cc @@ -69,6 +69,7 @@ static int _clua_panic(lua_State *); static void _clua_throttle_hook(lua_State *, lua_Debug *); static void *_clua_allocator(void *ud, void *ptr, size_t osize, size_t nsize); static int _clua_guarded_pcall(lua_State *); +static int _clua_require(lua_State *); static int _clua_dofile(lua_State *); static int _clua_loadfile(lua_State *); @@ -637,6 +638,8 @@ void CLua::init_lua() lua_register(_state, "loadfile", _clua_loadfile); lua_register(_state, "dofile", _clua_dofile); + lua_register(_state, "require", _clua_require); + execfile("clua/util.lua", true, true); if (managed_vm) @@ -2929,6 +2932,20 @@ static int _clua_loadfile(lua_State *ls) return (1); } +static int _clua_require(lua_State *ls) +{ + const char *file = luaL_checkstring(ls, 1); + if (!file) + return (0); + + CLua &vm(CLua::get_vm(ls)); + if (vm.execfile(file, false, false) != 0) + luaL_error(ls, vm.error.c_str()); + + lua_pushboolean(ls, true); + return (1); +} + static int _clua_dofile(lua_State *ls) { const char *file = luaL_checkstring(ls, 1); |