Ambiance: Sort sounds by distance
This commit is contained in:
parent
a3e9658b2e
commit
1ec146706b
@ -138,10 +138,13 @@ if minetest.settings:get_bool("ambiance_enable") == true then
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Pick a random node and check if it can play a sound.
|
table.sort(nodeposses, function(p1, p2)
|
||||||
-- If yes, take it. If not, try with the next one
|
return vector.distance(p1, pos) < vector.distance(p2, pos)
|
||||||
-- until the list is exhausted.
|
end)
|
||||||
table.shuffle(nodeposses)
|
|
||||||
|
-- Pick the closest node and check if it can play a sound,
|
||||||
|
-- If yes, take it. If not, try with the next-closest one
|
||||||
|
-- and try again. Repeat until the list is exhausted.
|
||||||
for n=1, #nodeposses do
|
for n=1, #nodeposses do
|
||||||
local nodepos = nodeposses[n]
|
local nodepos = nodeposses[n]
|
||||||
-- Check can_play function. If nil, can play sound.
|
-- Check can_play function. If nil, can play sound.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user