2016-06-08 03:53:41 +02:00
|
|
|
local function register_rope_block(multiple, pixels)
|
2017-02-01 03:53:16 +01:00
|
|
|
minetest.register_node(string.format("ropes:%irope_block", multiple), {
|
|
|
|
description = string.format("Rope %im", ropes.ropeLength*multiple),
|
2017-01-30 19:30:53 +01:00
|
|
|
_doc_items_create_entry = false,
|
2016-06-08 03:53:41 +02:00
|
|
|
drawtype="nodebox",
|
|
|
|
sunlight_propagates = true,
|
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "wallmounted",
|
|
|
|
tiles = {
|
2017-02-01 03:53:16 +01:00
|
|
|
string.format("default_wood.png^ropes_%irope.png", multiple),
|
|
|
|
string.format("default_wood.png^ropes_%irope.png", multiple),
|
|
|
|
"default_wood.png^ropes_side.png",
|
|
|
|
"default_wood.png^ropes_side.png",
|
2017-02-01 04:03:21 +01:00
|
|
|
string.format("default_wood.png^(ropes_%irope.png^[mask:ropes_mask.png)", multiple),
|
|
|
|
string.format("default_wood.png^(ropes_%irope.png^[mask:ropes_mask.png)", multiple),
|
2016-06-08 03:53:41 +02:00
|
|
|
},
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.375, -0.1875, -0.3125, 0.375, 0.375, 0.3125}, -- Spool
|
|
|
|
{-0.5, -0.5, -0.1875, -0.375, 0.25, 0.1875}, -- Support_arm
|
|
|
|
{0.375, -0.5, -0.1875, 0.5, 0.25, 0.1875}, -- Support_arm
|
|
|
|
{-0.375, -0.5, -0.1875, 0.375, -0.375, 0.1875}, -- Base
|
|
|
|
{-0.0625*(pixels/2), -0.1875, -0.5, 0.0625*(pixels/2), 0.375, 0.5}, -- Longitudinal_rope
|
|
|
|
{-0.0625*(pixels/2), -0.3125, -0.375, 0.0625*(pixels/2), 0.5, 0.375}, -- Vertical_rope
|
|
|
|
},
|
|
|
|
},
|
|
|
|
selection_box = {type="regular"},
|
|
|
|
collision_box = {type="regular"},
|
2017-01-30 09:56:44 +01:00
|
|
|
groups = {flammable=2, choppy=2, oddly_breakable_by_hand=1},
|
2016-06-08 03:53:41 +02:00
|
|
|
|
|
|
|
after_place_node = function(pos)
|
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)
|
|
|
|
if node_below.name == "air" then
|
2017-02-01 03:53:16 +01:00
|
|
|
minetest.add_node(pos_below, {name="ropes:rope_bottom"})
|
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.ropeLength*multiple)
|
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-01 03:53:16 +01:00
|
|
|
ropes.destroy_rope_starting(pos_below, 'ropes:rope', 'ropes:rope_bottom', 'ropes:rope_top')
|
2016-06-08 03:53:41 +02:00
|
|
|
end
|
|
|
|
})
|
|
|
|
|
2017-02-01 03:53:16 +01:00
|
|
|
if (multiple ~= 1) then
|
2016-06-08 03:53:41 +02:00
|
|
|
local rec = {}
|
|
|
|
for i=1,multiple,1 do
|
2017-02-01 03:53:16 +01:00
|
|
|
rec[i] = "ropes:1rope_block"
|
2016-06-08 03:53:41 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_craft({
|
2017-02-01 03:53:16 +01:00
|
|
|
output = string.format("ropes:%irope_block", multiple),
|
2016-06-08 03:53:41 +02:00
|
|
|
type = "shapeless",
|
|
|
|
recipe = rec
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
2017-02-01 03:53:16 +01:00
|
|
|
output = string.format("ropes:1rope_block %i", multiple),
|
2016-06-08 03:53:41 +02:00
|
|
|
recipe = {
|
2017-02-01 03:53:16 +01:00
|
|
|
{string.format('ropes:%irope_block', multiple)}
|
2016-06-08 03:53:41 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
end
|
2017-01-30 19:30:53 +01:00
|
|
|
|
|
|
|
if minetest.get_modpath("doc") then
|
2017-02-01 03:53:16 +01:00
|
|
|
doc.add_entry_alias("nodes", "ropes:rope", "nodes", string.format("ropes:%irope_block", multiple))
|
2017-01-30 19:30:53 +01:00
|
|
|
end
|
2016-06-08 03:53:41 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--creates rope blocks with length multiples 1-5.
|
|
|
|
--second parameter sets how many pixels wide the rope texture is
|
|
|
|
register_rope_block(1, 4)
|
|
|
|
register_rope_block(2, 8)
|
|
|
|
register_rope_block(3, 10)
|
|
|
|
register_rope_block(4, 10)
|
|
|
|
register_rope_block(5, 12)
|
|
|
|
|
2017-02-01 03:53:16 +01:00
|
|
|
minetest.register_node("ropes:rope", {
|
2017-01-30 09:56:44 +01:00
|
|
|
description = "Rope",
|
2017-02-01 03:53:16 +01:00
|
|
|
_doc_items_longdesc = ropes.doc.ropebox_longdesc,
|
|
|
|
_doc_items_usagehelp = ropes.doc.ropebox_usage,
|
2017-01-30 09:56:44 +01:00
|
|
|
walkable = false,
|
|
|
|
climbable = true,
|
|
|
|
sunlight_propagates = true,
|
|
|
|
paramtype = "light",
|
|
|
|
drop = "",
|
2017-02-01 03:53:16 +01:00
|
|
|
tiles = { "ropes_rope.png" },
|
2017-01-30 09:56:44 +01:00
|
|
|
drawtype = "plantlike",
|
|
|
|
groups = {choppy=2, flammable=2, not_in_creative_inventory=1},
|
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
|
|
|
|
},
|
|
|
|
after_destruct = function(pos)
|
2017-02-01 03:53:16 +01:00
|
|
|
ropes.hanging_after_destruct(pos, "ropes:rope_top", "ropes:rope", "ropes:rope_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:rope_bottom", {
|
2017-01-30 09:56:44 +01:00
|
|
|
description = "Rope",
|
2017-01-30 19:30:53 +01:00
|
|
|
_doc_items_create_entry = false,
|
2017-01-30 09:56:44 +01:00
|
|
|
walkable = false,
|
|
|
|
climbable = true,
|
|
|
|
sunlight_propagates = true,
|
|
|
|
paramtype = "light",
|
|
|
|
drop = "",
|
2017-02-01 03:53:16 +01:00
|
|
|
tiles = { "ropes_rope_bottom.png" },
|
2017-01-30 09:56:44 +01:00
|
|
|
drawtype = "plantlike",
|
|
|
|
groups = {choppy=2, flammable=2, not_in_creative_inventory=1},
|
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
|
|
|
|
},
|
|
|
|
|
|
|
|
on_construct = function( pos )
|
|
|
|
local timer = minetest.get_node_timer( pos )
|
|
|
|
timer:start( 1 )
|
|
|
|
end,
|
|
|
|
|
|
|
|
on_timer = function( pos, elapsed )
|
|
|
|
local currentend = minetest.get_node(pos)
|
|
|
|
local currentmeta = minetest.get_meta(pos)
|
|
|
|
local currentlength = currentmeta:get_int("length_remaining")
|
|
|
|
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 == "air" and (currentlength > 1) then
|
2017-02-01 03:53:16 +01:00
|
|
|
minetest.add_node(pos_below, {name="ropes:rope_bottom"})
|
2017-01-30 09:56:44 +01:00
|
|
|
local newmeta = minetest.get_meta(pos_below)
|
|
|
|
newmeta:set_int("length_remaining", currentlength-1)
|
2017-02-01 03:53:16 +01:00
|
|
|
minetest.set_node(pos, {name="ropes:rope"})
|
2017-01-30 09:56:44 +01:00
|
|
|
else
|
|
|
|
local timer = minetest.get_node_timer( pos )
|
|
|
|
timer:start( 1 )
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
after_destruct = function(pos)
|
2017-02-01 03:53:16 +01:00
|
|
|
ropes.hanging_after_destruct(pos, "ropes:rope_top", "ropes:rope", "ropes:rope_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:rope_top", {
|
2017-01-30 09:56:44 +01:00
|
|
|
description = "Rope",
|
2017-01-30 19:30:53 +01:00
|
|
|
_doc_items_create_entry = false,
|
2017-01-30 09:56:44 +01:00
|
|
|
walkable = false,
|
|
|
|
climbable = true,
|
|
|
|
sunlight_propagates = true,
|
|
|
|
paramtype = "light",
|
|
|
|
drop = "",
|
2017-02-01 03:53:16 +01:00
|
|
|
tiles = { "ropes_rope_top.png" },
|
2017-01-30 09:56:44 +01:00
|
|
|
drawtype = "plantlike",
|
|
|
|
groups = {not_in_creative_inventory=1},
|
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
|
|
|
|
},
|
|
|
|
|
|
|
|
on_construct = function( pos )
|
|
|
|
local timer = minetest.get_node_timer( pos )
|
2016-06-08 03:53:41 +02:00
|
|
|
timer:start( 1 )
|
2017-01-30 09:56:44 +01:00
|
|
|
end,
|
|
|
|
|
|
|
|
on_timer = function( pos, elapsed )
|
|
|
|
local p = {x=pos.x, y=pos.y-1, z=pos.z}
|
|
|
|
local n = minetest.get_node(p)
|
|
|
|
|
|
|
|
if (n.name ~= "ignore") then
|
2017-02-01 03:53:16 +01:00
|
|
|
ropes.destroy_rope_starting(p, 'ropes:rope', 'ropes:rope_bottom', 'ropes:rope_top')
|
2017-01-30 09:56:44 +01:00
|
|
|
minetest.swap_node(pos, {name="air"})
|
|
|
|
else
|
|
|
|
local timer = minetest.get_node_timer( pos )
|
|
|
|
timer:start( 1 )
|
|
|
|
end
|
|
|
|
end,
|
2016-06-08 03:53:41 +02:00
|
|
|
})
|