2017-02-10 05:29:42 +01:00
|
|
|
if ropes.ropeLadderLength == 0 and not ropes.create_all_definitions then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2020-02-20 05:57:13 +01:00
|
|
|
local S = ropes.S
|
2017-02-03 08:22:31 +01:00
|
|
|
|
2017-02-10 05:29:42 +01:00
|
|
|
if ropes.ropeLadderLength > 0 then
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "ropes:ropeladder_top",
|
|
|
|
recipe = {
|
|
|
|
{'','group:stick',''},
|
|
|
|
{'group:vines','group:stick','group:vines'},
|
|
|
|
{'','group:stick',''},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
type = "fuel",
|
|
|
|
recipe = "ropes:ropeladder_top",
|
|
|
|
burntime = ropes.ladder_burn_time,
|
|
|
|
})
|
|
|
|
|
|
|
|
local rope_ladder_top_def = {
|
2017-02-03 08:22:31 +01:00
|
|
|
description = S("Rope Ladder"),
|
2017-02-01 03:53:16 +01:00
|
|
|
_doc_items_longdesc = ropes.doc.ropeladder_longdesc,
|
|
|
|
_doc_items_usagehelp = ropes.doc.ropeladder_usage,
|
2016-06-08 03:53:41 +02:00
|
|
|
drawtype = "signlike",
|
2017-02-01 03:53:16 +01:00
|
|
|
tiles = {"default_ladder_wood.png^ropes_ropeladder_top.png"},
|
2021-03-13 10:22:06 +01:00
|
|
|
use_texture_alpha = "clip",
|
2016-06-08 03:53:41 +02:00
|
|
|
is_ground_content = false,
|
2017-02-01 03:53:16 +01:00
|
|
|
inventory_image = "default_ladder_wood.png^ropes_ropeladder_top.png",
|
|
|
|
wield_image = "default_ladder_wood.png^ropes_ropeladder_top.png",
|
2016-06-08 03:53:41 +02:00
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "wallmounted",
|
|
|
|
walkable = false,
|
|
|
|
climbable = true,
|
2016-06-08 09:30:00 +02:00
|
|
|
sunlight_propagates = true,
|
2016-06-08 03:53:41 +02:00
|
|
|
selection_box = {
|
|
|
|
type = "wallmounted",
|
|
|
|
--wall_top = = <default>
|
|
|
|
--wall_bottom = = <default>
|
|
|
|
--wall_side = = <default>
|
|
|
|
|
|
|
|
},
|
|
|
|
groups = { choppy=2, oddly_breakable_by_hand=1,flammable=2},
|
|
|
|
sounds = default.node_sound_wood_defaults(),
|
2017-04-30 19:54:39 +02:00
|
|
|
|
|
|
|
on_place = function(itemstack, placer, pointed_thing)
|
|
|
|
if pointed_thing.type == "node" then
|
|
|
|
local target_node = minetest.get_node(pointed_thing.under)
|
|
|
|
local target_def = minetest.registered_nodes[target_node.name]
|
|
|
|
if target_def.walkable == false then
|
|
|
|
return itemstack
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return minetest.item_place(itemstack, placer, pointed_thing)
|
|
|
|
end,
|
2016-06-08 03:53:41 +02:00
|
|
|
|
2017-02-02 03:27:53 +01:00
|
|
|
after_place_node = function(pos, placer)
|
2017-01-30 09:56:44 +01:00
|
|
|
local pos_below = {x=pos.x, y=pos.y-1, z=pos.z}
|
|
|
|
local node_below = minetest.get_node(pos_below)
|
|
|
|
local this_node = minetest.get_node(pos)
|
2017-02-02 03:27:53 +01:00
|
|
|
local placer_name = placer:get_player_name()
|
2016-06-08 03:53:41 +02:00
|
|
|
-- param2 holds the facing direction of this node. If it's 0 or 1 the node is "flat" and we don't want the ladder to extend.
|
2019-06-30 03:51:01 +02:00
|
|
|
if ropes.can_place_rope_in_node(node_below.name) and this_node.param2 > 1
|
2017-02-05 21:52:02 +01:00
|
|
|
and (not minetest.is_protected(pos_below, placer_name)
|
|
|
|
or minetest.check_player_privs(placer_name, "protection_bypass")) then
|
2017-02-01 03:53:16 +01:00
|
|
|
minetest.add_node(pos_below, {name="ropes:ropeladder_bottom", param2=this_node.param2})
|
2017-01-30 09:56:44 +01:00
|
|
|
local meta = minetest.get_meta(pos_below)
|
2017-02-01 03:53:16 +01:00
|
|
|
meta:set_int("length_remaining", ropes.ropeLadderLength)
|
2017-02-02 03:27:53 +01:00
|
|
|
meta:set_string("placer", placer_name)
|
2016-06-08 03:53:41 +02:00
|
|
|
end
|
|
|
|
end,
|
2016-06-08 09:30:00 +02:00
|
|
|
after_destruct = function(pos)
|
2017-01-30 09:56:44 +01:00
|
|
|
local pos_below = {x=pos.x, y=pos.y-1, z=pos.z}
|
2017-02-09 08:34:17 +01:00
|
|
|
ropes.destroy_rope(pos_below, {"ropes:ropeladder", "ropes:ropeladder_bottom", "ropes:ropeladder_falling"})
|
2017-01-30 09:56:44 +01:00
|
|
|
end,
|
2017-02-10 05:29:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ropes.ropeLadderLength == 0 then
|
|
|
|
rope_ladder_top_def.groups.not_in_creative_inventory = 1
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_node("ropes:ropeladder_top", rope_ladder_top_def)
|
2016-06-08 03:53:41 +02:00
|
|
|
|
2017-02-01 03:53:16 +01:00
|
|
|
minetest.register_node("ropes:ropeladder", {
|
2017-02-03 08:22:31 +01:00
|
|
|
description = S("Rope Ladder"),
|
2017-01-30 19:30:53 +01:00
|
|
|
_doc_items_create_entry = false,
|
2017-01-30 09:56:44 +01:00
|
|
|
drop = "",
|
2016-06-08 03:53:41 +02:00
|
|
|
drawtype = "signlike",
|
2017-02-01 03:53:16 +01:00
|
|
|
tiles = {"default_ladder_wood.png^ropes_ropeladder.png"},
|
2021-03-13 10:22:06 +01:00
|
|
|
use_texture_alpha = "clip",
|
2016-06-08 03:53:41 +02:00
|
|
|
is_ground_content = false,
|
2017-02-01 03:53:16 +01:00
|
|
|
inventory_image = "default_ladder_wood.png^ropes_ropeladder.png",
|
|
|
|
wield_image = "default_ladder_wood.png^ropes_ropeladder.png",
|
2016-06-08 03:53:41 +02:00
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "wallmounted",
|
|
|
|
walkable = false,
|
|
|
|
climbable = true,
|
2016-06-08 09:30:00 +02:00
|
|
|
sunlight_propagates = true,
|
2016-06-08 03:53:41 +02:00
|
|
|
selection_box = {
|
|
|
|
type = "wallmounted",
|
|
|
|
--wall_top = = <default>
|
|
|
|
--wall_bottom = = <default>
|
|
|
|
--wall_side = = <default>
|
|
|
|
},
|
2017-01-30 09:56:44 +01:00
|
|
|
groups = {choppy=2, flammable=2, not_in_creative_inventory=1},
|
2016-06-08 03:53:41 +02:00
|
|
|
sounds = default.node_sound_wood_defaults(),
|
2017-01-30 09:56:44 +01:00
|
|
|
|
|
|
|
after_destruct = function(pos)
|
2017-02-01 03:53:16 +01:00
|
|
|
ropes.hanging_after_destruct(pos, "ropes:ropeladder_falling", "ropes:ropeladder", "ropes:ropeladder_bottom")
|
2017-01-30 09:56:44 +01:00
|
|
|
end,
|
2016-06-08 03:53:41 +02:00
|
|
|
})
|
|
|
|
|
2017-02-09 08:34:17 +01:00
|
|
|
local ladder_extender = ropes.make_rope_on_timer("ropes:ropeladder")
|
|
|
|
|
2017-02-01 03:53:16 +01:00
|
|
|
minetest.register_node("ropes:ropeladder_bottom", {
|
2017-02-03 08:22:31 +01:00
|
|
|
description = S("Rope Ladder"),
|
2017-01-30 19:30:53 +01:00
|
|
|
_doc_items_create_entry = false,
|
2017-01-30 09:56:44 +01:00
|
|
|
drop = "",
|
2016-06-08 03:53:41 +02:00
|
|
|
drawtype = "signlike",
|
2017-02-01 03:53:16 +01:00
|
|
|
tiles = {"default_ladder_wood.png^ropes_ropeladder_bottom.png"},
|
2021-03-13 10:22:06 +01:00
|
|
|
use_texture_alpha = "clip",
|
2016-06-08 03:53:41 +02:00
|
|
|
is_ground_content = false,
|
2017-02-01 03:53:16 +01:00
|
|
|
inventory_image = "default_ladder_wood.png^ropes_ropeladder_bottom.png",
|
|
|
|
wield_image = "default_ladder_wood.png^ropes_ropeladder_bottom.png",
|
2016-06-08 03:53:41 +02:00
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "wallmounted",
|
|
|
|
walkable = false,
|
|
|
|
climbable = true,
|
2016-06-08 09:30:00 +02:00
|
|
|
sunlight_propagates = true,
|
2016-06-08 03:53:41 +02:00
|
|
|
selection_box = {
|
|
|
|
type = "wallmounted",
|
|
|
|
--wall_top = = <default>
|
|
|
|
--wall_bottom = = <default>
|
|
|
|
--wall_side = = <default>
|
|
|
|
|
|
|
|
},
|
2017-01-30 09:56:44 +01:00
|
|
|
groups = {choppy=2, flammable=2, not_in_creative_inventory=1},
|
2016-06-08 03:53:41 +02:00
|
|
|
sounds = default.node_sound_wood_defaults(),
|
|
|
|
on_construct = function( pos )
|
|
|
|
local timer = minetest.get_node_timer( pos )
|
|
|
|
timer:start( 1 )
|
|
|
|
end,
|
2017-02-09 08:34:17 +01:00
|
|
|
on_timer = ladder_extender,
|
2017-01-30 09:56:44 +01:00
|
|
|
|
|
|
|
after_destruct = function(pos)
|
2017-02-01 03:53:16 +01:00
|
|
|
ropes.hanging_after_destruct(pos, "ropes:ropeladder_falling", "ropes:ropeladder", "ropes:ropeladder_bottom")
|
2017-01-30 09:56:44 +01:00
|
|
|
end,
|
2016-06-08 03:53:41 +02:00
|
|
|
})
|
|
|
|
|
2017-02-01 03:53:16 +01:00
|
|
|
minetest.register_node("ropes:ropeladder_falling", {
|
2017-02-03 08:22:31 +01:00
|
|
|
description = S("Rope Ladder"),
|
2017-01-30 19:30:53 +01:00
|
|
|
_doc_items_create_entry = false,
|
2017-01-30 09:56:44 +01:00
|
|
|
drop = "",
|
2016-06-08 03:53:41 +02:00
|
|
|
drawtype = "signlike",
|
2017-02-01 03:53:16 +01:00
|
|
|
tiles = {"default_ladder_wood.png^ropes_ropeladder.png"},
|
2021-03-13 10:22:06 +01:00
|
|
|
use_texture_alpha = "clip",
|
2016-06-08 03:53:41 +02:00
|
|
|
is_ground_content = false,
|
2017-02-01 03:53:16 +01:00
|
|
|
inventory_image = "default_ladder_wood.png^ropes_ropeladder.png",
|
|
|
|
wield_image = "default_ladder_wood.png^ropes_ropeladder.png",
|
2016-06-08 03:53:41 +02:00
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "wallmounted",
|
|
|
|
walkable = false,
|
|
|
|
climbable = true,
|
2016-06-08 09:30:00 +02:00
|
|
|
sunlight_propagates = true,
|
2016-06-08 03:53:41 +02:00
|
|
|
selection_box = {
|
|
|
|
type = "wallmounted",
|
|
|
|
--wall_top = = <default>
|
|
|
|
--wall_bottom = = <default>
|
|
|
|
--wall_side = = <default>
|
|
|
|
|
|
|
|
},
|
|
|
|
groups = {flammable=2, not_in_creative_inventory=1},
|
|
|
|
sounds = default.node_sound_wood_defaults(),
|
|
|
|
on_construct = function( pos )
|
|
|
|
local timer = minetest.get_node_timer( pos )
|
|
|
|
timer:start( 1 )
|
|
|
|
end,
|
|
|
|
on_timer = function( pos, elapsed )
|
2017-01-30 09:56:44 +01:00
|
|
|
local pos_below = {x=pos.x, y=pos.y-1, z=pos.z}
|
|
|
|
local node_below = minetest.get_node(pos_below)
|
2016-06-08 09:30:00 +02:00
|
|
|
|
2017-01-30 09:56:44 +01:00
|
|
|
if (node_below.name ~= "ignore") then
|
2017-02-09 08:34:17 +01:00
|
|
|
ropes.destroy_rope(pos_below, {'ropes:ropeladder', 'ropes:ropeladder_bottom', 'ropes:ropeladder_falling'})
|
2017-01-30 09:56:44 +01:00
|
|
|
minetest.swap_node(pos, {name="air"})
|
2016-06-08 03:53:41 +02:00
|
|
|
else
|
|
|
|
local timer = minetest.get_node_timer( pos )
|
|
|
|
timer:start( 1 )
|
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|