1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
if ropes.ropeLadderLength == 0 and not ropes.create_all_definitions then
return
end
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
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 = {
description = S("Rope Ladder"),
_doc_items_longdesc = ropes.doc.ropeladder_longdesc,
_doc_items_usagehelp = ropes.doc.ropeladder_usage,
drawtype = "signlike",
tiles = {"default_ladder_wood.png^ropes_ropeladder_top.png"},
is_ground_content = false,
inventory_image = "default_ladder_wood.png^ropes_ropeladder_top.png",
wield_image = "default_ladder_wood.png^ropes_ropeladder_top.png",
paramtype = "light",
paramtype2 = "wallmounted",
walkable = false,
climbable = true,
sunlight_propagates = true,
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(),
after_place_node = function(pos, placer)
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)
local placer_name = placer:get_player_name()
-- 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.
if node_below.name == "air" and this_node.param2 > 1
and (not minetest.is_protected(pos_below, placer_name)
or minetest.check_player_privs(placer_name, "protection_bypass")) then
minetest.add_node(pos_below, {name="ropes:ropeladder_bottom", param2=this_node.param2})
local meta = minetest.get_meta(pos_below)
meta:set_int("length_remaining", ropes.ropeLadderLength)
meta:set_string("placer", placer_name)
end
end,
after_destruct = function(pos)
local pos_below = {x=pos.x, y=pos.y-1, z=pos.z}
ropes.destroy_rope(pos_below, {"ropes:ropeladder", "ropes:ropeladder_bottom", "ropes:ropeladder_falling"})
end,
}
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)
minetest.register_node("ropes:ropeladder", {
description = S("Rope Ladder"),
_doc_items_create_entry = false,
drop = "",
drawtype = "signlike",
tiles = {"default_ladder_wood.png^ropes_ropeladder.png"},
is_ground_content = false,
inventory_image = "default_ladder_wood.png^ropes_ropeladder.png",
wield_image = "default_ladder_wood.png^ropes_ropeladder.png",
paramtype = "light",
paramtype2 = "wallmounted",
walkable = false,
climbable = true,
sunlight_propagates = true,
selection_box = {
type = "wallmounted",
--wall_top = = <default>
--wall_bottom = = <default>
--wall_side = = <default>
},
groups = {choppy=2, flammable=2, not_in_creative_inventory=1},
sounds = default.node_sound_wood_defaults(),
after_destruct = function(pos)
ropes.hanging_after_destruct(pos, "ropes:ropeladder_falling", "ropes:ropeladder", "ropes:ropeladder_bottom")
end,
})
local ladder_extender = ropes.make_rope_on_timer("ropes:ropeladder")
minetest.register_node("ropes:ropeladder_bottom", {
description = S("Rope Ladder"),
_doc_items_create_entry = false,
drop = "",
drawtype = "signlike",
tiles = {"default_ladder_wood.png^ropes_ropeladder_bottom.png"},
is_ground_content = false,
inventory_image = "default_ladder_wood.png^ropes_ropeladder_bottom.png",
wield_image = "default_ladder_wood.png^ropes_ropeladder_bottom.png",
paramtype = "light",
paramtype2 = "wallmounted",
walkable = false,
climbable = true,
sunlight_propagates = true,
selection_box = {
type = "wallmounted",
--wall_top = = <default>
--wall_bottom = = <default>
--wall_side = = <default>
},
groups = {choppy=2, 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 = ladder_extender,
after_destruct = function(pos)
ropes.hanging_after_destruct(pos, "ropes:ropeladder_falling", "ropes:ropeladder", "ropes:ropeladder_bottom")
end,
})
minetest.register_node("ropes:ropeladder_falling", {
description = S("Rope Ladder"),
_doc_items_create_entry = false,
drop = "",
drawtype = "signlike",
tiles = {"default_ladder_wood.png^ropes_ropeladder.png"},
is_ground_content = false,
inventory_image = "default_ladder_wood.png^ropes_ropeladder.png",
wield_image = "default_ladder_wood.png^ropes_ropeladder.png",
paramtype = "light",
paramtype2 = "wallmounted",
walkable = false,
climbable = true,
sunlight_propagates = true,
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 )
local pos_below = {x=pos.x, y=pos.y-1, z=pos.z}
local node_below = minetest.get_node(pos_below)
if (node_below.name ~= "ignore") then
ropes.destroy_rope(pos_below, {'ropes:ropeladder', 'ropes:ropeladder_bottom', 'ropes:ropeladder_falling'})
minetest.swap_node(pos, {name="air"})
else
local timer = minetest.get_node_timer( pos )
timer:start( 1 )
end
end
})
|