summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dat/lua/eat.lua
blob: ff335f1a8ce28b3b78ff009ad924fc3b78eddeb9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
---------------------------------------------------------------------------
-- 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