Use drinking sound for milk and soups

This commit is contained in:
Wuzzy 2017-02-16 15:08:26 +01:00
parent e3cea8ffdc
commit c587d6316e
6 changed files with 39 additions and 26 deletions

2
API.md
View File

@ -81,7 +81,7 @@ These groups are used mostly for informational purposes
* `minecart=1`: Minecart * `minecart=1`: Minecart
* `food`: Item is a comestible item which can be consumed (healthy or unhealthy) * `food`: Item is a comestible item which can be consumed (healthy or unhealthy)
* `food=2`: Food * `food=2`: Food
* `food=3`: Drink * `food=3`: Drink (including soups)
* `food=1`: Other/unsure * `food=1`: Other/unsure
* `eatable`: Item can be *directly* eaten by wielding + left click (`on_use=item_eat`). Rating is the satiation gain * `eatable`: Item can be *directly* eaten by wielding + left click (`on_use=item_eat`). Rating is the satiation gain
* `ammo=1`: Item is used as ammo for a weapon * `ammo=1`: Item is used as ammo for a weapon

View File

@ -102,7 +102,7 @@ minetest.register_craftitem("mcl_farming:beetroot_soup", {
inventory_image = "mcl_farming_beetroot_soup.png", inventory_image = "mcl_farming_beetroot_soup.png",
wield_image = "mcl_farming_beetroot_soup.png", wield_image = "mcl_farming_beetroot_soup.png",
on_use = minetest.item_eat(6, "mcl_core:bowl"), on_use = minetest.item_eat(6, "mcl_core:bowl"),
groups = { food = 1, eatable = 6 }, groups = { food = 3, eatable = 6 },
}) })
minetest.register_craft({ minetest.register_craft({

View File

@ -37,7 +37,7 @@ minetest.register_craftitem("mcl_farming:mushroom_stew", {
description = "Mushroom Stew", description = "Mushroom Stew",
inventory_image = "farming_mushroom_stew.png", inventory_image = "farming_mushroom_stew.png",
on_use = minetest.item_eat(6, "mcl_core:bowl"), on_use = minetest.item_eat(6, "mcl_core:bowl"),
groups = { food = 2, eatable = 6 }, groups = { food = 3, eatable = 6 },
stack_max = 1, stack_max = 1,
}) })

View File

@ -49,5 +49,6 @@ This mod is free software.
* `hbhunger_bar.png—Wuzzy` (WTFPL) * `hbhunger_bar.png—Wuzzy` (WTFPL)
* `hbhunger_icon_health_poison.png`—celeron55 ([CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/)), modified by BlockMen, modified again by Wuzzy * `hbhunger_icon_health_poison.png`—celeron55 ([CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/)), modified by BlockMen, modified again by Wuzzy
* `mcl_hunger_bite.1.ogg`, `mcl_hungr_bite.2.ogg`: WTFPL * `mcl_hunger_bite.1.ogg`, `mcl_hungr_bite.2.ogg`: WTFPL
* `survival_thirst_drink.ogg`: WTFPL
* Everything else: WTFPL, by BlockMen and Wuzzy * Everything else: WTFPL, by BlockMen and Wuzzy

View File

@ -78,33 +78,45 @@ function mcl_hunger.item_eat(hunger_change, replace_with_item, poisen, heal, sou
local h = tonumber(mcl_hunger.hunger[name]) local h = tonumber(mcl_hunger.hunger[name])
local hp = user:get_hp() local hp = user:get_hp()
-- Add eat particle effect and sound
local pos = user:getpos() local pos = user:getpos()
pos.y = pos.y + item_drop_settings.player_collect_height pos.y = pos.y + item_drop_settings.player_collect_height
local texture = minetest.registered_items[itemname].inventory_image local texture = minetest.registered_items[itemname].inventory_image
-- FIXME: Is this correct? o_O
minetest.add_item(pos, drop) minetest.add_item(pos, drop)
minetest.add_particlespawner({ local foodtype = minetest.get_item_group(itemname, "food")
amount = 20, if foodtype == 3 then
time = 0.1, -- Item is a drink, only play drinking sound (no particle)
minpos = {x=pos.x, y=pos.y, z=pos.z}, minetest.sound_play("survival_thirst_drink", {
maxpos = {x=pos.x, y=pos.y, z=pos.z}, pos = pos,
minvel = {x=-1, y=1, z=-1}, max_hear_distance = 12,
maxvel = {x=1, y=2, z=1}, gain = 1.0,
minacc = {x=0, y=-5, z=0}, })
maxacc = {x=0, y=-9, z=0}, else
minexptime = 1, -- Assume the item is a food
maxexptime = 1, -- Add eat particle effect and sound
minsize = 1, minetest.add_particlespawner({
maxsize = 2, amount = 20,
collisiondetection = true, time = 0.1,
vertical = false, minpos = {x=pos.x, y=pos.y, z=pos.z},
texture = texture, maxpos = {x=pos.x, y=pos.y, z=pos.z},
}) minvel = {x=-1, y=1, z=-1},
minetest.sound_play("mcl_hunger_bite", { maxvel = {x=1, y=2, z=1},
pos = pos, minacc = {x=0, y=-5, z=0},
max_hear_distance = 8, maxacc = {x=0, y=-9, z=0},
gain = 10.0, minexptime = 1,
}) maxexptime = 1,
minsize = 1,
maxsize = 2,
collisiondetection = true,
vertical = false,
texture = texture,
})
minetest.sound_play("mcl_hunger_bite", {
pos = pos,
max_hear_distance = 12,
gain = 1.0,
})
end
-- Saturation -- Saturation
if h < 20 and hunger_change then if h < 20 and hunger_change then