diff options
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/docs/crawl_manual.txt | 8 | ||||
-rw-r--r-- | crawl-ref/docs/crawl_options.txt | 73 | ||||
-rw-r--r-- | crawl-ref/init.txt | 2 | ||||
-rw-r--r-- | crawl-ref/source/acr.cc | 42 | ||||
-rw-r--r-- | crawl-ref/source/clua.cc | 22 |
5 files changed, 100 insertions, 47 deletions
diff --git a/crawl-ref/docs/crawl_manual.txt b/crawl-ref/docs/crawl_manual.txt index dad4f5e928..f964d0d4ed 100644 --- a/crawl-ref/docs/crawl_manual.txt +++ b/crawl-ref/docs/crawl_manual.txt @@ -420,10 +420,10 @@ available as well, including this manual. You can also read the logbook from there by pressing ':'. Note that both level map mode and targeting interface have their own help screens; again, press '?'. -If you don't like the standard keyset (either because some keys do not -work properly, or because you want to decrease the amount of typing -necessary), you can use keymaps and macros. See macro.txt in the Docs -directory, or read it from the in-game help menu. +If you don't like the standard keyset (either because some keys do not +work properly, or because you want to decrease the amount of typing +necessary), you can use keymaps and macros. See crawl_macro.txt in the +Docs directory, or read it from the in-game help menu. -------------------------------------------------------------------------------- diff --git a/crawl-ref/docs/crawl_options.txt b/crawl-ref/docs/crawl_options.txt index 011c645153..493cb083a3 100644 --- a/crawl-ref/docs/crawl_options.txt +++ b/crawl-ref/docs/crawl_options.txt @@ -94,10 +94,13 @@ The contents of this text are: cset_ibm, cset_dec, cset_unicode, feature, mon_glyph 6-b DOS and Windows. dos_use_background_intensity -6-c Unix +6-c Unix. background, use_fake_cursor 7- Inline Lua. +7-a Executing lua. +7-b Conditional options. +7-c Including external files. -------------------------------------------------------------------------------- @@ -1241,8 +1244,8 @@ flush.message = false command -- whenever the game is about to get the next command message -- whenever the game outputs a non-mute message -4-o Tiles Options ---------------------- +4-o Tiles Options. +---------------------- In non-tile games the tile options are ignored. show_items = <glyphs> @@ -1628,8 +1631,8 @@ dos_use_background_intensity = false characters (and setting this option to false may be advisable to preserve your sanity in such cases). -6-c Unix ------------- +6-c Unix. +------------- background = black Sets the default background colour by name (defaults to BLACK). @@ -1644,20 +1647,28 @@ use_fake_cursor = false darkgrey/black squares. -7- Inline Lua -============== +7- Inline Lua. +=============== -Lua code can be used directly in your init.txt/.crawlrc. You can use Lua -to selectively include parts of your init.txt (based on character type, -for instance) using this syntax: +7-a Executing lua. +---------------------- -< Lua code > -or -< -Lua code -> -or -: Lua code till end of line +Lua code can be used directly in your init.txt/.crawlrc. You can +execute Lua code using the following syntax. + +: Single line of lua code + +< Possibly multi-line + Lua code > + +{ Possibly multi-line + Lua code } + +In the second and third cases, the restriction is that the delimiter +characters appear at the beginning and end of a line, respectively. +The difference between the <> and {} is when the code gets executed. +Code {}, it is executed right away. Other Lua code is executed only +after the entire init file is read in. Examples: @@ -1665,21 +1676,41 @@ Examples: : crawl.mpr("Hello " .. you.name()) < -# Another welcome message +-- Another welcome message (lua code uses lua comments) crawl.mpr("Hi there") > -# Controlling visibility of options: +{ +function ch_autopickup(it) [ ... body omitted ... ] end +} + +7-b Conditional options. +---------------------------- + +You can use Lua to selectively include parts of your init.txt (based +on character type, for instance) using the same syntax. + +Examples: + : if you.race() == "Mummy" then autopickup = $?+"/ : else autopickup = $?+"/!% : end - or - : if you.race() == "Hill Orc" then priest = Beogh : else priest = Yredelemnul : end + +7-c Including external files. +--------------------------------- + +You can use Lua to include options from other files. This is actually +just a particularly useful way to use the previously discussed features. + +Example: + +# Set the monster glyphs back to the way they were in 0.3.4 +: crawl.read_options('docs/monsters_034.rc') diff --git a/crawl-ref/init.txt b/crawl-ref/init.txt index ded010c94b..92effc2423 100644 --- a/crawl-ref/init.txt +++ b/crawl-ref/init.txt @@ -302,7 +302,7 @@ show_items = !?/%=([)X}+\_. # # See crawl_options.txt for the options # cset_ascii, cset_ibm, cset_dec, cset_unicode, cset_any, -# feature, mon_glyph +# feature, mon_glyph, read_options ##### 6-b DOS and Windows ####################### diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 09db1d0a7b..fbbcff2fa5 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -3764,18 +3764,32 @@ static bool initialise(void) burden_change(); make_hungry(0,true); - you.redraw_strength = true; + you.redraw_strength = true; you.redraw_intelligence = true; - you.redraw_dexterity = true; + you.redraw_dexterity = true; you.redraw_armour_class = true; - you.redraw_evasion = true; - you.redraw_experience = true; - you.redraw_gold = true; - you.wield_change = true; - you.quiver_change = true; + you.redraw_evasion = true; + you.redraw_experience = true; + you.redraw_gold = true; + you.wield_change = true; + you.quiver_change = true; you.start_time = time( NULL ); // start timer on session +#ifdef CLUA_BINDINGS + clua.runhook("chk_startgame", "b", newc); + std::string yname = you.your_name; + read_init_file(true); + Options.fixup_options(); + strncpy(you.your_name, yname.c_str(), kNameLen); + you.your_name[kNameLen - 1] = 0; + + // In case Lua changed the character set. + init_char_table(Options.char_set); + init_feature_table(); + init_monster_symbols(); +#endif + draw_border(); new_level(); update_turn_count(); @@ -3793,20 +3807,6 @@ static bool initialise(void) zap_los_monsters(); } -#ifdef CLUA_BINDINGS - clua.runhook("chk_startgame", "b", newc); - std::string yname = you.your_name; - read_init_file(true); - Options.fixup_options(); - strncpy(you.your_name, yname.c_str(), kNameLen); - you.your_name[kNameLen - 1] = 0; - - // In case Lua changed the character set. - init_char_table(Options.char_set); - init_feature_table(); - init_monster_symbols(); -#endif - set_cursor_enabled(false); viewwindow(1, false); // This just puts the view up for the first turn. diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc index be10393602..85fca69605 100644 --- a/crawl-ref/source/clua.cc +++ b/crawl-ref/source/clua.cc @@ -1774,6 +1774,27 @@ static int crawl_setopt(lua_State *ls) return (0); } +static int crawl_read_options(lua_State *ls) +{ + if (!lua_isstring(ls, 1)) + return (0); + + const char* filename = lua_tostring(ls, 1); + FILE* f = fopen( filename, "r" ); + if (f) + { + FileLineInput fl(f); + Options.read_options(fl, true); + fclose(f); + } + else + { + mprf(MSGCH_WARN, "Warning: could not read options file '%s'", filename); + } + + return (0); +} + static int crawl_bindkey(lua_State *ls) { const char *s = NULL; @@ -2008,6 +2029,7 @@ static const struct luaL_reg crawl_lib[] = { "runmacro", crawl_runmacro }, { "bindkey", crawl_bindkey }, { "setopt", crawl_setopt }, + { "read_options", crawl_read_options }, { "msgch_num", crawl_msgch_num }, { "msgch_name", crawl_msgch_name }, |