diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-06-25 19:54:59 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-06-25 19:54:59 +0000 |
commit | 7ce53143a6ea781bb9bd2eb29995c6d160331328 (patch) | |
tree | 3a9aa283080572b5cc8fbb0eb9f30a8cdb55e465 /crawl-ref/source/util | |
parent | 648c698c072f989a8e351efbac07a0c9afb9b638 (diff) | |
download | crawl-ref-7ce53143a6ea781bb9bd2eb29995c6d160331328.tar.gz crawl-ref-7ce53143a6ea781bb9bd2eb29995c6d160331328.zip |
.des files can use a global Lua prelude (before maps are defined) that runs
at start of game, before any maps are loaded, and does not run in the context
of any specific map.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1654 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/util')
-rw-r--r-- | crawl-ref/source/util/levcomp.ypp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/crawl-ref/source/util/levcomp.ypp b/crawl-ref/source/util/levcomp.ypp index fb82c36e00..0a3cb8ada1 100644 --- a/crawl-ref/source/util/levcomp.ypp +++ b/crawl-ref/source/util/levcomp.ypp @@ -89,6 +89,7 @@ definition : def {} ; def : defdepth {} + | global_lua {} ; defdepth : DEFAULT_DEPTH STRING @@ -104,6 +105,15 @@ defdepth : DEFAULT_DEPTH STRING level : name map_specs { lc_map.set_file(lc_desfile); + + if (lc_run_global_prelude && !lc_global_prelude.empty()) + { + lc_global_prelude.set_file(lc_desfile); + lc_run_global_prelude = false; + if (lc_global_prelude.load_call(dlua, NULL)) + yyerror( lc_global_prelude.orig_error().c_str() ); + } + std::string err = lc_map.validate(); if (!err.empty()) yyerror(err.c_str()); @@ -164,6 +174,17 @@ metaline : place | prelude_lua ; +global_lua : MAIN global_lua_lines { } + +global_lua_lines : /* empty */ { } + | global_lua_lines global_lua_line { } + ; + +global_lua_line : LUA_LINE + { + lc_global_prelude.add(yylineno, $1); + } + main_lua : MAIN main_lua_lines { } main_lua_lines : /* empty */ { } |