1
0
mirror of https://codeberg.org/tenplus1/ambience.git synced 2025-07-15 23:10:25 +02:00

Compare commits

...

2 Commits

Author SHA1 Message Date
4acc464a8a add nil check for eye level 2021-10-29 07:36:23 +01:00
e19fca8446 fix nil check 2021-07-13 16:05:42 +01:00

View File

@ -104,7 +104,8 @@ end)
local get_ambience = function(player, tod, name) local get_ambience = function(player, tod, name)
-- play server or local music if music enabled and music not already playing -- play server or local music if music enabled and music not already playing
if play_music and MUSICVOLUME > 0 and playing[name].music < 0 then if play_music and MUSICVOLUME > 0
and playing[name] and playing[name].music < 0 then
-- count backwards -- count backwards
playing[name].music = playing[name].music -1 playing[name].music = playing[name].music -1
@ -133,13 +134,14 @@ local get_ambience = function(player, tod, name)
-- get foot and head level nodes at player position -- get foot and head level nodes at player position
local pos = player:get_pos() ; if not pos then return end local pos = player:get_pos() ; if not pos then return end
local prop = player:get_properties() local prop = player:get_properties()
local eyeh = prop.eye_height or 1.47 -- eye level with fallback
pos.y = pos.y + prop.eye_height -- eye level pos.y = pos.y + eyeh
local nod_head = pplus and name and playerplus[name] local nod_head = pplus and name and playerplus[name]
and playerplus[name].nod_head or minetest.get_node(pos).name and playerplus[name].nod_head or minetest.get_node(pos).name
pos.y = (pos.y - prop.eye_height) + 0.2 -- foot level pos.y = (pos.y - eyeh) + 0.2 -- foot level
local nod_feet = pplus and name and playerplus[name] local nod_feet = pplus and name and playerplus[name]
and playerplus[name].nod_feet or minetest.get_node(pos).name and playerplus[name].nod_feet or minetest.get_node(pos).name