Add support for fake players

This commit is contained in:
Wuzzy 2021-08-28 10:58:07 +02:00
parent ea958fbf6b
commit 2b385540eb
1 changed files with 18 additions and 8 deletions

View File

@ -79,14 +79,24 @@ function hbhunger.item_eat(hunger_change, replace_with_item, poisen, heal, sound
if h == nil or hp == nil then if h == nil or hp == nil then
return return
end end
minetest.sound_play( if user:is_player() then
{name = sound or "hbhunger_eat_generic", local object, object_pos
gain = 1}, -- Check if user is a "fake player" (unofficial imitation of a the player data structure)
{object=user, if type(user) == "userdata" then
max_hear_distance = 16, object = user
pitch = 1 + math.random(-10, 10)*0.005,}, else
true object_pos = user:get_pos()
) end
minetest.sound_play(
{name = sound or "hbhunger_eat_generic",
gain = 1},
{object=object,
pos=object_pos,
max_hear_distance = 16,
pitch = 1 + math.random(-10, 10)*0.005,},
true
)
end
-- Saturation -- Saturation
if h < hbhunger.SAT_MAX and hunger_change then if h < hbhunger.SAT_MAX and hunger_change then