Much enhanced rope blocks, added rope ladder

I did a bunch of work enhancing the rope blocks in this. I gave them a
nodebox model, limited the length the rope will extend to, allowed
blocks with rope of varying length to be crafted, and fixed a couple of
problems with ropes - namely that removing the block wouldn't
necessarily remove the whole rope (now there's a "rope top" that eats
its way down to ensure the whole rope is removed) and that a rope
couldn't be cut once it was in place. I also added a rope ladder
variant, and made it possible to craft ropes using cotton as well as
vines.

I may have broken the vines part of this mod in the process, I'll do
further testing and code cleanup soon.
This commit is contained in:
FaceDeer 2016-06-07 19:53:41 -06:00
parent 1ac1892d56
commit 2a5a536fd6
33 changed files with 402 additions and 112 deletions

@ -1,9 +1,10 @@
# Vines
## Features
- Rope block for spawning rope that slowly drops into the deep.
- Rope blocks for spawning rope that slowly drops into the deep.
- Rope ladder that similarly descends into the deep.
- Vines are climbable and slowly grow downward.
- Shears that allow the collecting of vines.
- Shears that allow the collecting of vines and the trimming of ropes
- Spawns vines on jungletree leaves.
- Roots on the bottom of dirt and dirt with grass nodes.
- Spawns vines on trees located in swampy area.

@ -1,14 +1,16 @@
minetest.register_craft({
output = 'vines:rope_block',
recipe = vines.recipes['rope_block']
})
-- Misc
minetest.register_craft({
output = 'vines:shears',
recipe = vines.recipes['shears']
output = 'vines:ropesegment',
recipe = {
{'farming:cotton',},
{'farming:cotton',},
{'farming:cotton'}
}
})
minetest.register_craftitem("vines:vines", {
description = "Vines",
minetest.register_craftitem("vines:ropesegment", {
description = "Rope",
groups = {vines = 1},
inventory_image = "vines_item.png",
})

@ -3,12 +3,18 @@ vines = {
recipes = {}
}
dofile( minetest.get_modpath( vines.name ) .. "/functions.lua" )
local enableVines = true
if enableVines then
dofile( minetest.get_modpath( vines.name ) .. "/functions.lua" )
end
dofile( minetest.get_modpath( vines.name ) .. "/aliases.lua" )
dofile( minetest.get_modpath( vines.name ) .. "/recipes.lua" )
dofile( minetest.get_modpath( vines.name ) .. "/crafts.lua" )
dofile( minetest.get_modpath( vines.name ) .. "/nodes.lua" )
dofile( minetest.get_modpath( vines.name ) .. "/ropeboxes.lua" )
dofile( minetest.get_modpath( vines.name ) .. "/ladder.lua" )
dofile( minetest.get_modpath( vines.name ) .. "/shear.lua" )
dofile( minetest.get_modpath( vines.name ) .. "/vines.lua" )
if enableVines then
dofile( minetest.get_modpath( vines.name ) .. "/vines.lua" )
end
print("[Vines] Loaded!")

159
ladder.lua Normal file

@ -0,0 +1,159 @@
local ropeLadderLength = 50
minetest.register_node("vines:ropeladder_top", {
description = "Rope ladder",
drawtype = "signlike",
tiles = {"default_ladder_wood.png^vines_ropeladder_top.png"},
is_ground_content = false,
inventory_image = "default_ladder_wood.png^vines_ropeladder_top.png",
wield_image = "default_ladder_wood.png^vines_ropeladder_top.png",
paramtype = "light",
paramtype2 = "wallmounted",
walkable = false,
climbable = true,
selection_box = {
type = "wallmounted",
--wall_top = = <default>
--wall_bottom = = <default>
--wall_side = = <default>
},
groups = { choppy=2, oddly_breakable_by_hand=1,flammable=2},
legacy_wallmounted = true,
sounds = default.node_sound_wood_defaults(),
after_place_node = function(pos)
local p = {x=pos.x, y=pos.y-1, z=pos.z}
local n = minetest.get_node(p)
local o = minetest.get_node(pos)
-- 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 n.name == "air" and o.param2 > 1 then
minetest.add_node(p, {name="vines:ropeladder_bottom", param2=o.param2})
local meta = minetest.get_meta(p)
meta:set_int("length_remaining", ropeLadderLength)
end
end,
after_dig_node = function(pos, node, digger)
local p = {x=pos.x, y=pos.y-1, z=pos.z}
local n = minetest.get_node(p)
if (n.name == 'vines:ropeladder' or n.name == 'vines:ropeladder_bottom' ) then
minetest.add_node(p, {name="vines:ropeladder_falling", param2=n.param2})
end
end
})
minetest.register_craft({
output = "vines:ropeladder_top",
recipe = {
{'group:vines','default:stick','group:vines'},
{'group:vines','default:stick','group:vines'},
}
})
minetest.register_node("vines:ropeladder", {
description = "Rope ladder",
drawtype = "signlike",
tiles = {"default_ladder_wood.png^vines_ropeladder.png"},
is_ground_content = false,
inventory_image = "default_ladder_wood.png^vines_ropeladder.png",
wield_image = "default_ladder_wood.png^vines_ropeladder.png",
paramtype = "light",
paramtype2 = "wallmounted",
walkable = false,
climbable = true,
selection_box = {
type = "wallmounted",
--wall_top = = <default>
--wall_bottom = = <default>
--wall_side = = <default>
},
groups = {flammable=2, not_in_creative_inventory=1},
legacy_wallmounted = true,
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("vines:ropeladder_bottom", {
description = "Rope ladder",
drawtype = "signlike",
tiles = {"default_ladder_wood.png^vines_ropeladder_bottom.png"},
is_ground_content = false,
inventory_image = "default_ladder_wood.png^vines_ropeladder_bottom.png",
wield_image = "default_ladder_wood.png^vines_ropeladder_bottom.png",
paramtype = "light",
paramtype2 = "wallmounted",
walkable = false,
climbable = true,
selection_box = {
type = "wallmounted",
--wall_top = = <default>
--wall_bottom = = <default>
--wall_side = = <default>
},
groups = {flammable=2, not_in_creative_inventory=1},
legacy_wallmounted = true,
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 currentend = minetest.get_node(pos)
local currentmeta = minetest.get_meta(pos)
local currentlength = currentmeta:get_int("length_remaining")
local p = {x=pos.x, y=pos.y-1, z=pos.z}
local n = minetest.get_node(p)
local o = minetest.get_node(pos)
if n.name == "air" and (currentlength > 1) then
minetest.add_node(p, {name="vines:ropeladder_bottom", param2=o.param2})
local newmeta = minetest.get_meta(p)
newmeta:set_int("length_remaining", currentlength-1)
minetest.set_node(pos, {name="vines:ropeladder", param2=o.param2})
else
local timer = minetest.get_node_timer( pos )
timer:start( 1 )
end
end
})
minetest.register_node("vines:ropeladder_falling", {
description = "Rope ladder",
drawtype = "signlike",
tiles = {"default_ladder_wood.png^vines_ropeladder.png"},
is_ground_content = false,
inventory_image = "default_ladder_wood.png^vines_ropeladder.png",
wield_image = "default_ladder_wood.png^vines_ropeladder.png",
paramtype = "light",
paramtype2 = "wallmounted",
walkable = false,
climbable = true,
selection_box = {
type = "wallmounted",
--wall_top = = <default>
--wall_bottom = = <default>
--wall_side = = <default>
},
groups = {flammable=2, not_in_creative_inventory=1},
legacy_wallmounted = true,
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 p = {x=pos.x, y=pos.y-1, z=pos.z}
local n = minetest.get_node(p)
local o = minetest.get_node(pos)
if (n.name == 'vines:ropeladder' or n.name == 'vines:ropeladder_bottom') then
minetest.add_node(p, {name="vines:ropeladder_falling", param2=o.param2})
end
if (n.name ~= "ignore") then
minetest.set_node(pos, {name="air"})
else
local timer = minetest.get_node_timer( pos )
timer:start( 1 )
end
end
})

@ -1,83 +0,0 @@
minetest.register_node("vines:rope_block", {
description = "Rope",
sunlight_propagates = true,
paramtype = "light",
tile_images = {
"default_wood.png^vines_rope.png",
"default_wood.png^vines_rope.png",
"default_wood.png",
"default_wood.png",
"default_wood.png^vines_rope.png",
"default_wood.png^vines_rope.png",
},
groups = { flammable=2, choppy=2, oddly_breakable_by_hand=1 },
after_place_node = function(pos)
local p = {x=pos.x, y=pos.y-1, z=pos.z}
local n = minetest.get_node(p)
if n.name == "air" then
minetest.add_node(p, {name="vines:rope_end"})
end
end,
after_dig_node = function(pos, node, digger)
local p = {x=pos.x, y=pos.y-1, z=pos.z}
local n = minetest.get_node(p)
while ( n.name == 'vines:rope' or n.name == 'vines:rope_end' ) do
minetest.remove_node(p)
p = {x=p.x, y=p.y-1, z=p.z}
n = minetest.get_node(p)
end
end
})
minetest.register_node("vines:rope", {
description = "Rope",
walkable = false,
climbable = true,
sunlight_propagates = true,
paramtype = "light",
drop = "",
tile_images = { "vines_rope.png" },
drawtype = "plantlike",
groups = {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},
},
})
minetest.register_node("vines:rope_end", {
description = "Rope",
walkable = false,
climbable = true,
sunlight_propagates = true,
paramtype = "light",
drop = "",
tile_images = { "vines_rope_end.png" },
drawtype = "plantlike",
groups = {flammable=2, not_in_creative_inventory=1},
sounds = default.node_sound_leaves_defaults(),
after_place_node = function(pos)
yesh = {x = pos.x, y= pos.y-1, z=pos.z}
minetest.add_node(yesh, {name="vines:rope"})
end,
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 p = {x=pos.x, y=pos.y-1, z=pos.z}
local n = minetest.get_node(p)
if n.name == "air" then
minetest.set_node(pos, {name="vines:rope"})
minetest.add_node(p, {name="vines:rope_end"})
else
local timer = minetest.get_node_timer( pos )
timer:start( 1 )
end
end
})

@ -1,12 +0,0 @@
vines.recipes['rope_block'] = {
{'', 'default:wood', ''},
{'', 'group:vines', ''},
{'', 'group:vines', ''}
}
vines.recipes['shears'] = {
{'', 'default:steel_ingot', ''},
{'default:stick', 'default:wood', 'default:steel_ingot'},
{'', '', 'default:stick'}
}

BIN
ropebox.nbe Normal file

Binary file not shown.

175
ropeboxes.lua Normal file

@ -0,0 +1,175 @@
local ropeLength = 100
local function register_rope_block(multiple, pixels)
minetest.register_node(string.format("vines:%irope_block", multiple), {
description = string.format("Rope %im", ropeLength*multiple),
drawtype="nodebox",
sunlight_propagates = true,
paramtype = "light",
paramtype2 = "wallmounted",
tiles = {
string.format("default_wood.png^vines_%irope.png", multiple),
string.format("default_wood.png^vines_%irope.png", multiple),
"default_wood.png^vines_side.png",
"default_wood.png^vines_side.png",
string.format("default_wood.png^vines_%irope_frontback.png", multiple),
string.format("default_wood.png^vines_%irope_frontback.png", multiple),
},
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"},
groups = { flammable=2, choppy=2, oddly_breakable_by_hand=1 },
after_place_node = function(pos)
local p = {x=pos.x, y=pos.y-1, z=pos.z}
local n = minetest.get_node(p)
if n.name == "air" then
minetest.add_node(p, {name="vines:rope_bottom"})
local meta = minetest.get_meta(p)
meta:set_int("length_remaining", ropeLength*multiple)
end
end,
after_dig_node = function(pos, node, digger)
local p = {x=pos.x, y=pos.y-1, z=pos.z}
local n = minetest.get_node(p)
if (n.name == 'vines:rope' or n.name == 'vines:rope_bottom' ) then
minetest.add_node(p, {name="vines:rope_top"})
end
end
})
if (multiple == 1) then
minetest.register_craft({
output = "vines:1rope_block",
recipe = {
{'default:wood',},
{'group:vines',},
{'group:vines'}
}
})
else
local rec = {}
for i=1,multiple,1 do
rec[i] = "vines:1rope_block"
end
minetest.register_craft({
output = string.format("vines:%irope_block", multiple),
type = "shapeless",
recipe = rec
})
minetest.register_craft({
output = string.format("vines:1rope_block %i", multiple),
recipe = {
{string.format('vines:%irope_block', multiple)}
}
})
end
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)
minetest.register_node("vines:rope", {
description = "Rope",
walkable = false,
climbable = true,
sunlight_propagates = true,
paramtype = "light",
drop = "",
tile_images = { "vines_rope.png" },
drawtype = "plantlike",
groups = {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},
},
})
minetest.register_node("vines:rope_bottom", {
description = "Rope",
walkable = false,
climbable = true,
sunlight_propagates = true,
paramtype = "light",
drop = "",
tile_images = { "vines_rope_bottom.png" },
drawtype = "plantlike",
groups = {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 p = {x=pos.x, y=pos.y-1, z=pos.z}
local n = minetest.get_node(p)
if n.name == "air" and (currentlength > 1) then
minetest.add_node(p, {name="vines:rope_bottom"})
local newmeta = minetest.get_meta(p)
newmeta:set_int("length_remaining", currentlength-1)
minetest.set_node(pos, {name="vines:rope"})
else
local timer = minetest.get_node_timer( pos )
timer:start( 1 )
end
end
})
minetest.register_node("vines:rope_top", {
description = "Rope",
walkable = false,
climbable = true,
sunlight_propagates = true,
paramtype = "light",
drop = "",
tile_images = { "vines_rope_top.png" },
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 )
timer:start( 1 )
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 == 'vines:rope' or n.name == 'vines:rope_bottom') then
minetest.add_node(p, {name="vines:rope_top"})
end
if (n.name ~= "ignore") then
minetest.set_node(pos, {name="air"})
else
local timer = minetest.get_node_timer( pos )
timer:start( 1 )
end
end
})

@ -1,15 +1,57 @@
local USES = 200
minetest.register_tool("vines:shears", {
description = "Shears",
inventory_image = "vines_shears.png",
wield_image = "shears.png",
wield_image = "vines_shears.png",
stack_max = 1,
max_drop_level=3,
tool_capabilities = {
full_punch_interval = 1.0,
max_drop_level=0,
groupcaps={
snappy={times={[3]=0.2}, maxwear=0.05, maxlevel=3},
wool={times={[3]=0.2}, maxwear=0.05, maxlevel=3}
snappy={times={[3]=0.2}, uses=1/0.05, maxlevel=3},
wool={times={[3]=0.2}, uses=1/0.05, maxlevel=3}
}
},
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then
return
end
local pos = pointed_thing.under
if minetest.is_protected(pos, user:get_player_name()) then
minetest.record_protection_violation(pos, user:get_player_name())
return
end
local node = minetest.get_node(pos)
if node.name == "vines:rope" then
itemstack:add_wear(65535 / (USES - 1))
minetest.add_node(pos, {name="vines:rope_bottom"})
local p = {x=pos.x, y=pos.y-1, z=pos.z}
local n = minetest.get_node(p)
if (n.name == 'vines:rope' or n.name == 'vines:rope_bottom') then
minetest.add_node(p, {name="vines:rope_top"})
end
end
if node.name == "vines:ropeladder" then
itemstack:add_wear(65535 / (USES - 1))
minetest.add_node(pos, {name="vines:ropeladder_bottom", param2=node.param2})
local p = {x=pos.x, y=pos.y-1, z=pos.z}
local n = minetest.get_node(p)
if (n.name == 'vines:ropeladder' or n.name == 'vines:ropeladder_bottom') then
minetest.add_node(p, {name="vines:ropeladder_falling", param2=n.param2})
end
end
end
})
minetest.register_craft({
output = 'vines:shears',
recipe = {
{'', 'default:steel_ingot', ''},
{'default:stick', 'default:wood', 'default:steel_ingot'},
{'', 'default:stick', ''}
}
})

BIN
textures/vines_1rope.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
textures/vines_2rope.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

BIN
textures/vines_3rope.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B

BIN
textures/vines_4rope.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

BIN
textures/vines_5rope.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 B

After

Width:  |  Height:  |  Size: 153 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 497 B

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 481 B

After

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 B

After

Width:  |  Height:  |  Size: 169 B

Before

Width:  |  Height:  |  Size: 118 B

After

Width:  |  Height:  |  Size: 118 B

BIN
textures/vines_rope_top.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 394 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 415 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 B

BIN
textures/vines_side.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 247 B

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 364 B

After

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 226 B

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 B

After

Width:  |  Height:  |  Size: 195 B