forked from nalc/homedecor_modpack
fix sounds not shutting off (and crash) when they should
This commit is contained in:
parent
c074e47bcd
commit
1e3c27e984
|
@ -211,14 +211,18 @@ homedecor.register("shower_head", {
|
||||||
|
|
||||||
local this_spawner_meta = minetest.get_meta(pos)
|
local this_spawner_meta = minetest.get_meta(pos)
|
||||||
local id = this_spawner_meta:get_int("active")
|
local id = this_spawner_meta:get_int("active")
|
||||||
|
local s_handle = this_spawner_meta:get_int("sound")
|
||||||
|
|
||||||
if id ~= 0 then
|
if id ~= 0 then
|
||||||
minetest.after(0, function(s_handle)
|
if s_handle then
|
||||||
minetest.sound_stop(s_handle)
|
minetest.after(0, function(s_handle)
|
||||||
end, s_handle)
|
minetest.sound_stop(s_handle)
|
||||||
|
end, s_handle)
|
||||||
|
end
|
||||||
local player = clicker:get_player_name()
|
local player = clicker:get_player_name()
|
||||||
minetest.delete_particlespawner(id, player)
|
minetest.delete_particlespawner(id, player)
|
||||||
this_spawner_meta:set_int("active", nil)
|
this_spawner_meta:set_int("active", nil)
|
||||||
|
this_spawner_meta:set_int("sound", nil)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -238,16 +242,27 @@ homedecor.register("shower_head", {
|
||||||
loop = true
|
loop = true
|
||||||
})
|
})
|
||||||
this_spawner_meta:set_int("active", id)
|
this_spawner_meta:set_int("active", id)
|
||||||
|
this_spawner_meta:set_int("sound", s_handle)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_destruct = function(pos)
|
on_destruct = function(pos)
|
||||||
local this_spawner_meta = minetest.get_meta(pos)
|
local this_spawner_meta = minetest.get_meta(pos)
|
||||||
local id = this_spawner_meta:get_int("active")
|
local id = this_spawner_meta:get_int("active")
|
||||||
|
local s_handle = this_spawner_meta:get_int("sound")
|
||||||
|
|
||||||
if id ~= 0 then
|
if id ~= 0 then
|
||||||
minetest.delete_particlespawner(id)
|
minetest.delete_particlespawner(id)
|
||||||
this_spawner_meta:set_int("active", nil)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if s_handle then
|
||||||
|
minetest.after(0, function(s_handle)
|
||||||
|
minetest.sound_stop(s_handle)
|
||||||
|
end, s_handle)
|
||||||
|
end
|
||||||
|
|
||||||
|
this_spawner_meta:set_int("active", nil)
|
||||||
|
this_spawner_meta:set_int("sound", nil)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user