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7FQTQC
YL67KHG3TAZXJCWGRZPVASD6RS2SQ3V5KMIUK4E6PV43V2NBOLEAC
72GIZBEMQLEF3TITOHABWHRLL5TE7KOUSVWOUEHFMO2OZQ4EIB7AC
3RCLZOPUS4SA463D5ZVHZE66MARNXBWOYXDOOR6IKZNKCCSXSX2AC
RV4L36J3DCVW3SONFFYAVK44XJQOFVNPGKHET7VOIFYHWZHCJRNAC
V6REAY6RCAG2QQ4BO54GHYOVTNCYHTLERJCIZJPSANXFBINZOTXAC
WL5WZXFJ6TONUQRSHUY4GQ5USU47ILWNN5X2JDQZO4CRJJZSRQIAC
QUFPPRIIRXHUFEDH3EFES7CSHTA7GG2DAXTRHUAUQBYMSWK4BP6AC
MCBXXIV6GICTZB56APSXMJEI63FVQWVZR3H2DRNMMFDH2XCGK4JAC
RVST2QHYJ757ZHK4AUJ5NGPDZ44AD6RVFVXYPKQIBJXZBDNUCHXQC
LH4OYDEWEON5QNUCM74R7MNBJDP7O4XRETY74ZMYSXUXYQV427PAC
UF4ODJOCV3ZL7DXRLLOFVWHUKKJX34FO4ZM6VJAWEJ3QVP3XZ2AAC
TDAVD56MGLFSMJLPLSYLEVW7MBRMT7V5BNII4TRWVDIHH47CD2OAC
EHSY6DVGUMI6C67WKET3GDJVLWJWGYBYQONNDK5JVT7BCTHBEZVAC
4VK7VHWRVRO66BRSGTBPSYJGGXLRF6AG6G74UDTPHTPXR7ZRNINQC
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
}
// 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);
}
}
---------------------------------------------------------------------------
-- eat.lua:
--
-- 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.
--
end
if food.prompt_floor() then
return
end
end
end
-- Allow the player to choose a snack from inventory.
food.prompt_inv_menu()
-- Prompt to eat a non-chunk from the inventory. Returns true if the player
-- ate something.
if food.prompt_inventory() then
return
-- Prompt to eat a non-chunk off the floor. Returns true if the player
-- ate something.
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
-- 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
# 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:
# 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