Update eating sound

This commit is contained in:
Wuzzy 2017-02-16 14:47:50 +01:00
parent 16bfda053d
commit 6912ca832c
6 changed files with 31 additions and 36 deletions

View File

@ -173,40 +173,6 @@ function minetest.item_drop(itemstack, dropper, pos)
end
end
--add food particles
function core.item_eat(hp_change, replace_with_item)
return function(itemstack, user, pointed_thing) -- closure
local pos = user:getpos()
pos.y = pos.y + item_drop_settings.player_collect_height
local itemname = itemstack:get_name()
local texture = minetest.registered_items[itemname].inventory_image
minetest.add_item(pos, drop)
minetest.add_particlespawner({
amount = 20,
time = 0.1,
minpos = {x=pos.x, y=pos.y, z=pos.z},
maxpos = {x=pos.x, y=pos.y, z=pos.z},
minvel = {x=-1, y=1, z=-1},
maxvel = {x=1, y=2, z=1},
minacc = {x=0, y=-5, z=0},
maxacc = {x=0, y=-9, z=0},
minexptime = 1,
maxexptime = 1,
minsize = 1,
maxsize = 2,
collisiondetection = true,
vertical = false,
texture = texture,
})
minetest.sound_play("bite_item_drop", {
pos = pos,
max_hear_distance = 100,
gain = 10.0,
})
return core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
end
end
--modify builtin:item
local time_to_live = tonumber(core.setting_get("item_entity_ttl"))

View File

@ -42,11 +42,12 @@ This mod is free software.
* Forked from `hbhunger` for MineClone 2. `hbhunger` in turn was forked from the “Better HUD
(and hunger)” mod by BlockMen (2013-2015), most code comes from this mod.
### Textures
### Textures and sounds
* `hbhunger_icon.png`—PilzAdam ([WTFPL](http://www.wtfpl.net/txt/copying/)), modified by BlockMen
* `hbhunger_bgicon.png`—PilzAdam (WTFPL), modified by BlockMen
* `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
* `bite_item_drop.1.ogg`, `bite_item_drop.2.ogg`: WTFPL
* Everything else: WTFPL, by BlockMen and Wuzzy

View File

@ -72,11 +72,39 @@ end
function mcl_hunger.item_eat(hunger_change, replace_with_item, poisen, heal, sound)
return function(itemstack, user, pointed_thing)
local itemname = itemstack:get_name()
if itemstack:take_item() ~= nil and user ~= nil then
local name = user:get_player_name()
local h = tonumber(mcl_hunger.hunger[name])
local hp = user:get_hp()
minetest.sound_play({name = sound or "mcl_hunger_eat_generic", gain = 1}, {pos=user:getpos(), max_hear_distance = 16})
-- Add eat particle effect and sound
local pos = user:getpos()
pos.y = pos.y + item_drop_settings.player_collect_height
local texture = minetest.registered_items[itemname].inventory_image
minetest.add_item(pos, drop)
minetest.add_particlespawner({
amount = 20,
time = 0.1,
minpos = {x=pos.x, y=pos.y, z=pos.z},
maxpos = {x=pos.x, y=pos.y, z=pos.z},
minvel = {x=-1, y=1, z=-1},
maxvel = {x=1, y=2, z=1},
minacc = {x=0, y=-5, z=0},
maxacc = {x=0, y=-9, z=0},
minexptime = 1,
maxexptime = 1,
minsize = 1,
maxsize = 2,
collisiondetection = true,
vertical = false,
texture = texture,
})
minetest.sound_play("bite_item_drop", {
pos = pos,
max_hear_distance = 8,
gain = 10.0,
})
-- Saturation
if h < 20 and hunger_change then

Binary file not shown.

Binary file not shown.