mirror of
https://git.minetest.land/Mineclonia/Mineclonia.git
synced 2024-11-19 22:55:10 +00:00
Fix another door openclose sound issue
This commit is contained in:
parent
7f6cc1b95e
commit
edb9f9521c
1 changed files with 11 additions and 8 deletions
|
@ -128,30 +128,33 @@ function mcl_doors:register_door(name, def)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function on_open_close(pos, dir, check_name, replace, replace_dir, params)
|
local function on_open_close(pos, dir, check_name, replace, replace_dir, params)
|
||||||
|
local meta1 = minetest.get_meta(pos)
|
||||||
pos.y = pos.y+dir
|
pos.y = pos.y+dir
|
||||||
|
local meta2 = minetest.get_meta(pos)
|
||||||
if not minetest.get_node(pos).name == check_name then
|
if not minetest.get_node(pos).name == check_name then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local p2 = minetest.get_node(pos).param2
|
local p2 = minetest.get_node(pos).param2
|
||||||
local np2 = params[p2+1]
|
local np2 = params[p2+1]
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos):to_table()
|
local metatable = minetest.get_meta(pos):to_table()
|
||||||
minetest.set_node(pos, {name=replace_dir, param2=np2})
|
minetest.set_node(pos, {name=replace_dir, param2=np2})
|
||||||
minetest.get_meta(pos):from_table(meta)
|
minetest.get_meta(pos):from_table(metatable)
|
||||||
|
|
||||||
pos.y = pos.y-dir
|
pos.y = pos.y-dir
|
||||||
meta = minetest.get_meta(pos):to_table()
|
metatable = minetest.get_meta(pos):to_table()
|
||||||
minetest.set_node(pos, {name=replace, param2=np2})
|
minetest.set_node(pos, {name=replace, param2=np2})
|
||||||
minetest.get_meta(pos):from_table(meta)
|
minetest.get_meta(pos):from_table(metatable)
|
||||||
|
|
||||||
local door_switching_sound
|
local door_switching_sound
|
||||||
local meta = minetest.get_meta(pos)
|
if meta1:get_int("is_open") == 1 then
|
||||||
if meta:get_int("is_open") == 1 then
|
|
||||||
door_switching_sound = def.sound_close
|
door_switching_sound = def.sound_close
|
||||||
meta:set_int("is_open", 0)
|
meta1:set_int("is_open", 0)
|
||||||
|
meta2:set_int("is_open", 0)
|
||||||
else
|
else
|
||||||
door_switching_sound = def.sound_open
|
door_switching_sound = def.sound_open
|
||||||
meta:set_int("is_open", 1)
|
meta1:set_int("is_open", 1)
|
||||||
|
meta2:set_int("is_open", 1)
|
||||||
end
|
end
|
||||||
minetest.sound_play(door_switching_sound, {pos = pos, gain = 0.5, max_hear_distance = 16})
|
minetest.sound_play(door_switching_sound, {pos = pos, gain = 0.5, max_hear_distance = 16})
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue