diff options
-rw-r--r-- | crawl-ref/settings/init.txt | 33 | ||||
-rw-r--r-- | crawl-ref/source/clua.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/dat/lua/eat.lua | 39 | ||||
-rw-r--r-- | crawl-ref/source/food.cc | 68 | ||||
-rw-r--r-- | crawl-ref/source/food.h | 4 | ||||
-rw-r--r-- | crawl-ref/source/item_use.cc | 2 |
6 files changed, 54 insertions, 96 deletions
diff --git a/crawl-ref/settings/init.txt b/crawl-ref/settings/init.txt index e44e912575..0e0834a792 100644 --- a/crawl-ref/settings/init.txt +++ b/crawl-ref/settings/init.txt @@ -1,11 +1,11 @@ # NOTE FOR PLAYERS OF OLD VERSIONS (DCSS 0.3.4 or before): # -# DCSS 0.4 introduces several rather drastic changes to the interface; -# read 034_changes.txt for details. Uncomment these options if you want -# to disable them and go back to the old state: +# DCSS 0.4 introduces several rather drastic changes to the interface; +# read 034_changes.txt for details. Uncomment these options if you want +# to disable them and go back to the old state: # monster colours, command keys, order on the character selection screen, -# item colours, appearance of the stat section, butchering interface, -# targeting interface. +# item colours, appearance of the stat section, butchering interface, +# targeting interface. # The options for monster glyphs and item colours don't matter for Tiles. # (New players should just ignore these lines.) # @@ -20,7 +20,7 @@ # Crawl Init file # -# On Unix systems (such as Mac OS X, Linux and the BSDs), you must copy +# On Unix systems (such as Mac OS X, Linux and the BSDs), you must copy # init.txt to ~/.crawlrc as: # cp init.txt ~/.crawlrc # @@ -34,14 +34,14 @@ # cases (the character's name and specifying files or directories when # on a system that has case-sensitive filenames). # -# White space is stripped from the beginning and end of the line, as -# well as immediately before and after the '='. If the option allows -# multiple comma/semicolon-separated terms (such as -# autopickup_exceptions), all whitespace around the separator is also +# White space is stripped from the beginning and end of the line, as +# well as immediately before and after the '='. If the option allows +# multiple comma/semicolon-separated terms (such as +# autopickup_exceptions), all whitespace around the separator is also # trimmed. All other whitespace is left intact. # -# For descriptions concerning an option consult the file -# options_guide.txt +# For descriptions concerning an option consult the file +# options_guide.txt # in your /docs directory. Also note that the ordering of the options # is taken from that file; this is for presentational reasons only. # @@ -80,7 +80,6 @@ lua_file = lua/stash.lua lua_file = lua/wield.lua lua_file = lua/runrest.lua lua_file = lua/gearset.lua -lua_file = lua/eat.lua lua_file = lua/trapwalk.lua lua_file = lua/pickup.lua @@ -90,7 +89,7 @@ lua_file = lua/pickup.lua ##### 4- Interface ################################################# # ##### 4-a Picking up and Dropping ############### -# +# autopickup = $?!+"/% # There is a long list of autopickup exceptions in @@ -174,7 +173,7 @@ auto_exclude = curse skull,Roxanne # tc_excluded = lightmagenta # tc_exclude_circle = red -# The following options are not default. +# The following options are not default. # runrest_ignore_message = pray: runrest_ignore_message = You feel.*sick @@ -193,7 +192,7 @@ trapwalk_safe_hp = dart:20,needle:15,arrow:35,bolt:45,spear:40,axe:45,blade:95 #rest_wait_both = true -# The file (travel_stoppers.txt) contains a list of travel_stop_message +# The file (travel_stoppers.txt) contains a list of travel_stop_message # settings, with brief descriptions of what they do. include = travel_stoppers.txt @@ -386,7 +385,7 @@ note_monsters = orb of fire, ancient lich, Sigmund # colour.yellow = brown # See options_guide.txt for the options -# cset_ascii, cset_ibm, cset_dec, cset_unicode, cset_any, +# cset_ascii, cset_ibm, cset_dec, cset_unicode, cset_any, # feature, mon_glyph ##### 6-b DOS and Windows ####################### diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc index e75261e300..f3acf7d44f 100644 --- a/crawl-ref/source/clua.cc +++ b/crawl-ref/source/clua.cc @@ -1618,7 +1618,7 @@ static int food_do_eat(lua_State *ls) { bool eaten = false; if (!you.turn_is_over) - eaten = eat_food(false); + eaten = eat_food(-1); lua_pushboolean(ls, eaten); return (1); } @@ -1627,7 +1627,7 @@ static int food_prompt_eat_chunks(lua_State *ls) { int eaten = 0; if (!you.turn_is_over) - eaten = eat_chunks(); + eaten = prompt_eat_chunks(); lua_pushboolean(ls, (eaten != 0)); return (1); diff --git a/crawl-ref/source/dat/lua/eat.lua b/crawl-ref/source/dat/lua/eat.lua deleted file mode 100644 index ff335f1a8c..0000000000 --- a/crawl-ref/source/dat/lua/eat.lua +++ /dev/null @@ -1,39 +0,0 @@ ---------------------------------------------------------------------------- --- eat.lua: --- Prompts to eat food in the following order: --- 1) for chunks on the floor *and* in inventory, sorted by age --- 2) for non-chunks on the floor --- 3) for non-chunks in inventory --- 4) opens the food menu of your inventory --- --- To use this, add this line to your init.txt: --- lua_file = lua/eat.lua --- --- See c_eat in this file if you want to tweak eating behaviour further. ---------------------------------------------------------------------------- - --- Called by Crawl. Note that once Crawl sees a c_eat function, it bypasses the --- built-in (e)at command altogether. --- -function c_eat() - -- Prompt to eat chunks off floor/inventory, sorted by age. - -- Returns true if the player chose to eat a chunk. - if food.prompt_eat_chunks() then - return - end - - -- Prompt to eat a non-chunk off the floor. Returns true if the player - -- ate something. - if food.prompt_floor() then - return - end - - -- Prompt to eat a non-chunk from the inventory. Returns true if the player - -- ate something. - if food.prompt_inventory() then - return - end - - -- Allow the player to choose a snack from inventory. - food.prompt_inv_menu() -end diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc index e71c73af4d..b43b43556d 100644 --- a/crawl-ref/source/food.cc +++ b/crawl-ref/source/food.cc @@ -734,21 +734,6 @@ void lua_push_inv_items(lua_State *ls = NULL) } } -static bool _userdef_eat_food() -{ -#ifdef CLUA_BINDINGS - lua_push_floor_items(clua.state()); - lua_push_inv_items(); - bool ret = clua.callfn("c_eat", 2, 0); - if (!ret && clua.error.length()) - mpr(clua.error.c_str()); - - return (ret); -#else - return (false); -#endif -} - bool prompt_eat_inventory_item(int slot) { if (inv_count() < 1) @@ -816,7 +801,7 @@ bool prompt_eat_inventory_item(int slot) } // [ds] Returns true if something was eaten. -bool eat_food(bool run_hook, int slot) +bool eat_food(int slot) { if (you.is_undead == US_UNDEAD) { @@ -833,18 +818,25 @@ bool eat_food(bool run_hook, int slot) return (false); } - // If user hook ran, we don't know whether something - // was eaten or not... - if (run_hook && _userdef_eat_food()) - return (false); - - if (igrd(you.pos()) != NON_ITEM && slot == -1) + int result; + // Skip the prompts if we already know what we're eating. + if (slot == -1) { - const int res = eat_from_floor(false); - if (res == 1) - return (true); - if (res == -1) - return (false); + result = prompt_eat_chunks(); + if (result == 1 || result == -1) + return (result > 0); + + if (result != -2) // else skip ahead to inventory + { + if (igrd(you.pos()) != NON_ITEM) + { + result = eat_from_floor(true); + if (result == 1) + return (true); + if (result == -1) + return (false); + } + } } return (prompt_eat_inventory_item(slot)); @@ -1505,11 +1497,13 @@ bool eat_from_inventory() return (false); } -bool eat_chunks() +// Returns -1 for cancel, 1 for eaten, 0 for not eaten, +// -2 for skip to inventory. +int prompt_eat_chunks() { // Herbivores cannot eat chunks. if (player_mutation_level(MUT_HERBIVOROUS) == 3) - return (false); + return (0); bool found_valid = false; std::vector<item_def *> chunks; @@ -1587,7 +1581,7 @@ bool eat_chunks() } else { - mprf(MSGCH_PROMPT, "%s %s%s? (ye/n/q)", + mprf(MSGCH_PROMPT, "%s %s%s? (ye/n/q/i?)", (you.species == SP_VAMPIRE ? "Drink blood from" : "Eat"), ((item->quantity > 1) ? "one of " : ""), item_name.c_str()); @@ -1599,7 +1593,11 @@ bool eat_chunks() case ESCAPE: case 'q': canned_msg(MSG_OK); - return (false); + return (-1); + case 'i': + case '?': + // Skip ahead to the inventory. + return (-2); case 'e': case 'y': if (can_ingest(item->base_type, item->sub_type, false)) @@ -1616,7 +1614,7 @@ bool eat_chunks() if (in_inventory(*item)) { eat_inventory_item(item->link); - return (true); + return (1); } else { @@ -1625,9 +1623,9 @@ bool eat_chunks() if (ilink != NON_ITEM) { eat_floor_item(ilink); - return (true); + return (1); } - return (false); + return (0); } } break; @@ -1638,7 +1636,7 @@ bool eat_chunks() } } - return (false); + return (0); } static const char *_chunk_flavour_phrase(bool likes_chunks) diff --git a/crawl-ref/source/food.h b/crawl-ref/source/food.h index 8ce977e6ee..f2da9ef993 100644 --- a/crawl-ref/source/food.h +++ b/crawl-ref/source/food.h @@ -49,7 +49,7 @@ bool butchery(int which_corpse = -1); /* *********************************************************************** * called from: acr * *********************************************************************** */ -bool eat_food(bool run_hook = true, int slot = -1); +bool eat_food(int slot = -1); // last updated 19jun2000 {dlb} @@ -94,7 +94,7 @@ void eat_floor_item(int item_link); int eat_from_floor(bool skip_chunks = true); bool eat_from_inventory(); -bool eat_chunks(); +int prompt_eat_chunks(); bool food_change(bool suppress_message = false); void eat_inventory_item(int which_inventory_slot); diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index ce003911da..269984cfa6 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -5385,7 +5385,7 @@ void tile_item_use(int idx) // intentional fall-through for Vampires case OBJ_FOOD: if (check_warning_inscriptions(item, OPER_EAT)) - eat_food(false, idx); + eat_food(idx); return; case OBJ_BOOKS: |