diff --git a/README.md b/README.md index 89fdb27..6aac52e 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/crafts.lua b/crafts.lua index 19e658b..271ae08 100644 --- a/crafts.lua +++ b/crafts.lua @@ -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", }) diff --git a/init.lua b/init.lua index 72eda93..2c973ec 100644 --- a/init.lua +++ b/init.lua @@ -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!") diff --git a/ladder.lua b/ladder.lua new file mode 100644 index 0000000..6f81c86 --- /dev/null +++ b/ladder.lua @@ -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 = = + --wall_bottom = = + --wall_side = = + + }, + 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 = = + --wall_bottom = = + --wall_side = = + + }, + 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 = = + --wall_bottom = = + --wall_side = = + + }, + 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 = = + --wall_bottom = = + --wall_side = = + + }, + 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 +}) diff --git a/nodes.lua b/nodes.lua deleted file mode 100644 index ab14b28..0000000 --- a/nodes.lua +++ /dev/null @@ -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 -}) diff --git a/recipes.lua b/recipes.lua deleted file mode 100644 index d2b928a..0000000 --- a/recipes.lua +++ /dev/null @@ -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'} -} - diff --git a/ropebox.nbe b/ropebox.nbe new file mode 100644 index 0000000..3ace7cd Binary files /dev/null and b/ropebox.nbe differ diff --git a/ropeboxes.lua b/ropeboxes.lua new file mode 100644 index 0000000..0ef1021 --- /dev/null +++ b/ropeboxes.lua @@ -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 +}) diff --git a/shear.lua b/shear.lua index 996cfdc..94ccb5e 100644 --- a/shear.lua +++ b/shear.lua @@ -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', ''} + } +}) \ No newline at end of file diff --git a/textures/vines_1rope.png b/textures/vines_1rope.png new file mode 100644 index 0000000..b2852a3 Binary files /dev/null and b/textures/vines_1rope.png differ diff --git a/textures/vines_1rope_frontback.png b/textures/vines_1rope_frontback.png new file mode 100644 index 0000000..3fe1558 Binary files /dev/null and b/textures/vines_1rope_frontback.png differ diff --git a/textures/vines_2rope.png b/textures/vines_2rope.png new file mode 100644 index 0000000..b7694dc Binary files /dev/null and b/textures/vines_2rope.png differ diff --git a/textures/vines_2rope_frontback.png b/textures/vines_2rope_frontback.png new file mode 100644 index 0000000..68441cd Binary files /dev/null and b/textures/vines_2rope_frontback.png differ diff --git a/textures/vines_3rope.png b/textures/vines_3rope.png new file mode 100644 index 0000000..e425185 Binary files /dev/null and b/textures/vines_3rope.png differ diff --git a/textures/vines_3rope_frontback.png b/textures/vines_3rope_frontback.png new file mode 100644 index 0000000..6f22d71 Binary files /dev/null and b/textures/vines_3rope_frontback.png differ diff --git a/textures/vines_4rope.png b/textures/vines_4rope.png new file mode 100644 index 0000000..697a379 Binary files /dev/null and b/textures/vines_4rope.png differ diff --git a/textures/vines_4rope_frontback.png b/textures/vines_4rope_frontback.png new file mode 100644 index 0000000..e6f7630 Binary files /dev/null and b/textures/vines_4rope_frontback.png differ diff --git a/textures/vines_5rope.png b/textures/vines_5rope.png new file mode 100644 index 0000000..3009ff3 Binary files /dev/null and b/textures/vines_5rope.png differ diff --git a/textures/vines_5rope_frontback.png b/textures/vines_5rope_frontback.png new file mode 100644 index 0000000..be9e70f Binary files /dev/null and b/textures/vines_5rope_frontback.png differ diff --git a/textures/vines_item.png b/textures/vines_item.png index c66242e..6f53f82 100644 Binary files a/textures/vines_item.png and b/textures/vines_item.png differ diff --git a/textures/vines_jungle_end.png b/textures/vines_jungle_end.png index 6c8d339..77c7f5a 100644 Binary files a/textures/vines_jungle_end.png and b/textures/vines_jungle_end.png differ diff --git a/textures/vines_jungle_middle.png b/textures/vines_jungle_middle.png index bf838a5..79e8429 100644 Binary files a/textures/vines_jungle_middle.png and b/textures/vines_jungle_middle.png differ diff --git a/textures/vines_root_end.png b/textures/vines_root_end.png index 4fc3f87..57be98b 100644 Binary files a/textures/vines_root_end.png and b/textures/vines_root_end.png differ diff --git a/textures/vines_rope_end.png b/textures/vines_rope_bottom.png similarity index 100% rename from textures/vines_rope_end.png rename to textures/vines_rope_bottom.png diff --git a/textures/vines_rope_top.png b/textures/vines_rope_top.png new file mode 100644 index 0000000..8964e96 Binary files /dev/null and b/textures/vines_rope_top.png differ diff --git a/textures/vines_ropeladder.png b/textures/vines_ropeladder.png new file mode 100644 index 0000000..e27a55c Binary files /dev/null and b/textures/vines_ropeladder.png differ diff --git a/textures/vines_ropeladder_bottom.png b/textures/vines_ropeladder_bottom.png new file mode 100644 index 0000000..71f91b0 Binary files /dev/null and b/textures/vines_ropeladder_bottom.png differ diff --git a/textures/vines_ropeladder_top.png b/textures/vines_ropeladder_top.png new file mode 100644 index 0000000..81a31ce Binary files /dev/null and b/textures/vines_ropeladder_top.png differ diff --git a/textures/vines_side.png b/textures/vines_side.png new file mode 100644 index 0000000..045d887 Binary files /dev/null and b/textures/vines_side.png differ diff --git a/textures/vines_side_end.png b/textures/vines_side_end.png index 5b3b28f..8f20414 100644 Binary files a/textures/vines_side_end.png and b/textures/vines_side_end.png differ diff --git a/textures/vines_vine_end.png b/textures/vines_vine_end.png index 062857b..dabef62 100644 Binary files a/textures/vines_vine_end.png and b/textures/vines_vine_end.png differ diff --git a/textures/vines_willow_end.png b/textures/vines_willow_end.png index b5b8e59..bdf327b 100644 Binary files a/textures/vines_willow_end.png and b/textures/vines_willow_end.png differ diff --git a/textures/vines_willow_middle.png b/textures/vines_willow_middle.png index ca0b831..5aef898 100644 Binary files a/textures/vines_willow_middle.png and b/textures/vines_willow_middle.png differ