Fix "double node" regressions
This commit is contained in:
parent
1c2489e308
commit
fb20e626f9
@ -18,7 +18,7 @@ function beds.register_bed(name, def)
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = def.selectionbox,
|
||||
|
||||
|
||||
},
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
local n = minetest.get_node_or_nil(pos)
|
||||
@ -36,7 +36,7 @@ function beds.register_bed(name, def)
|
||||
end
|
||||
minetest.set_node(p, {name = n.name:gsub("%_bottom", "_top"), param2 = n.param2})
|
||||
return false
|
||||
end,
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
local n = minetest.get_node_or_nil(pos)
|
||||
if not n then return end
|
||||
@ -99,6 +99,25 @@ function beds.register_bed(name, def)
|
||||
type = "fixed",
|
||||
fixed = {0, 0, 0, 0, 0, 0},
|
||||
},
|
||||
on_destruct = function(pos)
|
||||
local n = minetest.get_node_or_nil(pos)
|
||||
if not n then
|
||||
return
|
||||
end
|
||||
local f_dir = n.param2
|
||||
if f_dir < 2 then
|
||||
f_dir = f_dir + 2
|
||||
else
|
||||
f_dir = f_dir - 2
|
||||
end
|
||||
|
||||
local dir = minetest.facedir_to_dir(f_dir)
|
||||
local p = vector.add(pos, dir)
|
||||
local n2 = minetest.get_node(p)
|
||||
if minetest.get_item_group(n2.name, "bed") == 1 and n.param2 == n2.param2 then
|
||||
minetest.after(0, minetest.remove_node, p)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_alias(name, name .. "_bottom")
|
||||
|
@ -25,8 +25,8 @@ function doors.register_door(name, def)
|
||||
if not def.sound_open_door then
|
||||
def.sound_open_door = "doors_wooden_open"
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
minetest.register_craftitem(name, {
|
||||
description = def.description,
|
||||
inventory_image = def.inventory_image,
|
||||
@ -100,7 +100,7 @@ function doors.register_door(name, def)
|
||||
|
||||
local tt = def.tiles_top
|
||||
local tb = def.tiles_bottom
|
||||
|
||||
|
||||
local function after_dig_node(pos, name, digger)
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name == name then
|
||||
@ -108,7 +108,7 @@ function doors.register_door(name, def)
|
||||
end
|
||||
end
|
||||
|
||||
local function check_and_blast(pos, name)
|
||||
local function check_and_remove(pos, name)
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name == name then
|
||||
minetest.remove_node(pos)
|
||||
@ -120,9 +120,9 @@ function doors.register_door(name, def)
|
||||
return function() end
|
||||
else
|
||||
return function(pos, intensity)
|
||||
check_and_blast(pos, base_name .. door_type)
|
||||
check_and_remove(pos, base_name .. door_type)
|
||||
pos.y = pos.y + dir
|
||||
check_and_blast(pos, base_name .. other_door_type)
|
||||
check_and_remove(pos, base_name .. other_door_type)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -134,16 +134,16 @@ function doors.register_door(name, def)
|
||||
end
|
||||
local p2 = minetest.get_node(pos).param2
|
||||
p2 = params[p2+1]
|
||||
|
||||
|
||||
minetest.swap_node(pos, {name=replace_dir, param2=p2})
|
||||
|
||||
|
||||
pos.y = pos.y-dir
|
||||
minetest.swap_node(pos, {name=replace, param2=p2})
|
||||
|
||||
local snd_1 = def.sound_close_door
|
||||
local snd_2 = def.sound_open_door
|
||||
local snd_2 = def.sound_open_door
|
||||
if params[1] == 3 then
|
||||
snd_1 = def.sound_open_door
|
||||
snd_1 = def.sound_open_door
|
||||
snd_2 = def.sound_close_door
|
||||
end
|
||||
|
||||
@ -206,18 +206,18 @@ function doors.register_door(name, def)
|
||||
fixed = def.selection_box_bottom
|
||||
},
|
||||
groups = def.groups,
|
||||
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
pos.y = pos.y+1
|
||||
after_dig_node(pos, name.."_t_1", digger)
|
||||
end,
|
||||
|
||||
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
if check_player_priv(pos, clicker) then
|
||||
on_rightclick(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2", {1,2,3,0})
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
on_rotate = function(pos, node, user, mode, new_param2)
|
||||
return on_rotate(pos, node, 1, user, name.."_t_1", mode)
|
||||
end,
|
||||
@ -244,18 +244,18 @@ function doors.register_door(name, def)
|
||||
fixed = def.selection_box_top
|
||||
},
|
||||
groups = def.groups,
|
||||
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
pos.y = pos.y-1
|
||||
after_dig_node(pos, name.."_b_1", digger)
|
||||
end,
|
||||
|
||||
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
if check_player_priv(pos, clicker) then
|
||||
on_rightclick(pos, -1, name.."_b_1", name.."_t_2", name.."_b_2", {1,2,3,0})
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
on_rotate = function(pos, node, user, mode, new_param2)
|
||||
return on_rotate(pos, node, -1, user, name.."_b_1", mode)
|
||||
end,
|
||||
@ -263,7 +263,12 @@ function doors.register_door(name, def)
|
||||
can_dig = check_player_priv,
|
||||
sounds = def.sounds,
|
||||
sunlight_propagates = def.sunlight,
|
||||
on_blast = make_on_blast(name, -1, "_t_1", "_b_1")
|
||||
on_blast = make_on_blast(name, -1, "_t_1", "_b_1"),
|
||||
|
||||
on_destruct = function(pos)
|
||||
pos.y = pos.y - 1
|
||||
minetest.after(0, check_and_remove, pos, name .. "_b_1")
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node(name.."_b_2", {
|
||||
@ -282,18 +287,18 @@ function doors.register_door(name, def)
|
||||
fixed = def.selection_box_bottom
|
||||
},
|
||||
groups = def.groups,
|
||||
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
pos.y = pos.y+1
|
||||
after_dig_node(pos, name.."_t_2", digger)
|
||||
end,
|
||||
|
||||
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
if check_player_priv(pos, clicker) then
|
||||
on_rightclick(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1", {3,0,1,2})
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
on_rotate = function(pos, node, user, mode, new_param2)
|
||||
return on_rotate(pos, node, 1, user, name.."_t_2", mode)
|
||||
end,
|
||||
@ -320,18 +325,18 @@ function doors.register_door(name, def)
|
||||
fixed = def.selection_box_top
|
||||
},
|
||||
groups = def.groups,
|
||||
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
pos.y = pos.y-1
|
||||
after_dig_node(pos, name.."_b_2", digger)
|
||||
end,
|
||||
|
||||
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
if check_player_priv(pos, clicker) then
|
||||
on_rightclick(pos, -1, name.."_b_2", name.."_t_1", name.."_b_1", {3,0,1,2})
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
on_rotate = function(pos, node, user, mode, new_param2)
|
||||
return on_rotate(pos, node, -1, user, name.."_b_2", mode)
|
||||
end,
|
||||
@ -339,7 +344,12 @@ function doors.register_door(name, def)
|
||||
can_dig = check_player_priv,
|
||||
sounds = def.sounds,
|
||||
sunlight_propagates = def.sunlight,
|
||||
on_blast = make_on_blast(name, -1, "_t_2", "_b_2")
|
||||
on_blast = make_on_blast(name, -1, "_t_2", "_b_2"),
|
||||
|
||||
on_destruct = function(pos)
|
||||
pos.y = pos.y - 1
|
||||
minetest.after(0, check_and_remove, pos, name .. "_b_2")
|
||||
end
|
||||
})
|
||||
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user