mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-19 01:21:05 +01:00
Update trapdoor climbable behavior
This commit is contained in:
parent
b4c693bb20
commit
a960bf2e8e
2 changed files with 93 additions and 5 deletions
|
@ -33,7 +33,14 @@ minetest.register_node("mcl_core:ladder", {
|
|||
wall_side = { -0.5, -0.5, -0.5, -7/16, 0.5, 0.5 },
|
||||
},
|
||||
stack_max = 64,
|
||||
groups = {handy=1,axey=1, attached_node=1, deco_block=1, dig_by_piston=1},
|
||||
groups = {
|
||||
handy = 1,
|
||||
axey = 1,
|
||||
attached_node = 1,
|
||||
deco_block = 1,
|
||||
dig_by_piston = 1,
|
||||
ladder = 1
|
||||
},
|
||||
sounds = mcl_sounds.node_sound_wood_defaults(),
|
||||
node_placement_prediction = "",
|
||||
-- Restrict placement of ladders
|
||||
|
@ -80,7 +87,46 @@ minetest.register_node("mcl_core:ladder", {
|
|||
end
|
||||
return itemstack
|
||||
end,
|
||||
after_destruct = function(pos, oldnode)
|
||||
local pos_above = vector.add(pos, {x = 0, y = 1, z = 0 })
|
||||
local node_above = minetest.get_node_or_nil(pos_above)
|
||||
|
||||
if node_above then
|
||||
local is_trapdoor = minetest.get_item_group(node_above.name, "trapdoor")
|
||||
|
||||
-- If node above is an opened trapdoor
|
||||
if is_trapdoor == 2 then
|
||||
local above_def = minetest.registered_nodes[node_above.name]
|
||||
if above_def._other then
|
||||
minetest.swap_node(pos_above, {
|
||||
name = above_def._other,
|
||||
param1 = node_above.param1,
|
||||
param2 = node_above.param2,
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
after_place_node = function(pos, oldnode)
|
||||
local pos_above = vector.add(pos, {x = 0, y = 1, z = 0 })
|
||||
local node_above = minetest.get_node_or_nil(pos_above)
|
||||
|
||||
if node_above then
|
||||
local is_trapdoor = minetest.get_item_group(node_above.name, "trapdoor")
|
||||
|
||||
-- If node above is an opened trapdoor
|
||||
if is_trapdoor == 2 then
|
||||
local above_def = minetest.registered_nodes[node_above.name]
|
||||
if above_def._other then
|
||||
minetest.swap_node(pos_above, {
|
||||
name = above_def._other,
|
||||
param1 = node_above.param1,
|
||||
param2 = node_above.param2,
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
_mcl_blast_resistance = 0.4,
|
||||
_mcl_hardness = 0.4,
|
||||
on_rotate = rotate_climbable,
|
||||
|
|
|
@ -72,7 +72,21 @@ function mcl_doors:register_trapdoor(name, def)
|
|||
-- Open
|
||||
else
|
||||
minetest.sound_play(def.sound_open, {pos = pos, gain = 0.3, max_hear_distance = 16}, true)
|
||||
tmp_node = {name=name.."_open", param1=me.param1, param2=me.param2}
|
||||
|
||||
local bottom_node = minetest.get_node_or_nil(vector.subtract(pos, { x = 0, y = 1, z = 0 }))
|
||||
local name_end = "_open"
|
||||
|
||||
-- Checking if there is something underneath the trapdoor
|
||||
if bottom_node then
|
||||
local bottom_def = minetest.registered_nodes[bottom_node.name]
|
||||
local trapdoor = minetest.get_item_group(bottom_node.name, "trapdoor")
|
||||
|
||||
-- Changing trapdoor into a ladder if bottom node is climbable and not a trapdoor
|
||||
if trapdoor ~= 2 and bottom_def.climbable then
|
||||
name_end = "_ladder"
|
||||
end
|
||||
end
|
||||
tmp_node = {name=name..name_end, param1=me.param1, param2=me.param2}
|
||||
end
|
||||
minetest.set_node(pos, tmp_node)
|
||||
end
|
||||
|
@ -193,6 +207,7 @@ function mcl_doors:register_trapdoor(name, def)
|
|||
|
||||
groups_open.trapdoor = 2
|
||||
groups_open.not_in_creative_inventory = 1
|
||||
-- Non-climbable opened
|
||||
minetest.register_node(name.."_open", {
|
||||
drawtype = "nodebox",
|
||||
tiles = tiles_open,
|
||||
|
@ -200,9 +215,35 @@ function mcl_doors:register_trapdoor(name, def)
|
|||
is_ground_content = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
-- TODO: Implement Minecraft behaviour: Climbable if directly above
|
||||
-- ladder w/ matching orientation.
|
||||
-- Current behavour: Always climbable
|
||||
sunlight_propagates = true,
|
||||
pointable = true,
|
||||
groups = groups_open,
|
||||
_mcl_hardness = def._mcl_hardness,
|
||||
_mcl_blast_resistance = def._mcl_blast_resistance,
|
||||
sounds = def.sounds,
|
||||
drop = name,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, 5/16, 0.5, 0.5, 0.5}
|
||||
},
|
||||
on_rightclick = on_rightclick,
|
||||
mesecons = {effector = {
|
||||
action_off = (function(pos, node)
|
||||
punch(pos)
|
||||
end),
|
||||
}},
|
||||
on_rotate = on_rotate,
|
||||
_other = name .. "_ladder"
|
||||
})
|
||||
|
||||
-- Climbable opened
|
||||
minetest.register_node(name.."_ladder", {
|
||||
drawtype = "nodebox",
|
||||
tiles = tiles_open,
|
||||
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
|
||||
is_ground_content = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
climbable = true,
|
||||
sunlight_propagates = true,
|
||||
pointable = true,
|
||||
|
@ -222,6 +263,7 @@ function mcl_doors:register_trapdoor(name, def)
|
|||
end),
|
||||
}},
|
||||
on_rotate = on_rotate,
|
||||
_other = name .. "_open"
|
||||
})
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
|
|
Loading…
Reference in a new issue