diff --git a/init.lua b/init.lua index b4638c2..a889037 100644 --- a/init.lua +++ b/init.lua @@ -1,12 +1,22 @@ ---[[TODO - ropebox rope break results in bottom rope dissapearing and bottom drop rope node to appear at the new bottom - and rope does not drop anything!!!! -]] +vines = {} local mod_name = "vines" local average_height = 12 local spawn_interval = 90 -local vines_group = {attached_node=1,vines=1,snappy=3,flammable=2,hanging_node=1} +local vines_group = {attached_node=1,vines=1,snappy=3,flammable=2,hanging_node=1,vines_cleanup=1} + +vines.growth_interval = 300 +vines.growth_chance = 2 +vines.rot_interval = 300 +vines.rot_chance = 8 + +local jungle_leaves_list = { + "default:jungleleaves", + "moretrees:jungle_leaves_red", + "moretrees:jungle_leaves_yellow", + "moretrees:jungle_leaves_green" +} + -- Nodes minetest.register_node("vines:rope_block", { description = "Rope", @@ -92,6 +102,7 @@ minetest.register_node("vines:side", { sunlight_propagates = true, paramtype = "light", paramtype2 = "wallmounted", + buildable_to = true, tile_images = { "vines_side.png" }, drawtype = "signlike", inventory_image = "vines_side.png", @@ -119,10 +130,11 @@ minetest.register_node("vines:side_rotten", { sunlight_propagates = true, paramtype = "light", paramtype2 = "wallmounted", + buildable_to = true, tile_images = { "vines_side_rotten.png" }, drawtype = "signlike", inventory_image = "vines_side.png", - groups = {snappy = 3,flammable=2, hanging_node=1}, + groups = {snappy = 3,flammable=2, hanging_node=1,vines_cleanup=1}, sounds = default.node_sound_leaves_defaults(), selection_box = { type = "wallmounted", @@ -137,6 +149,7 @@ minetest.register_node("vines:willow", { sunlight_propagates = true, paramtype = "light", paramtype2 = "wallmounted", + buildable_to = true, tile_images = { "vines_willow.png" }, drawtype = "signlike", inventory_image = "vines_willow.png", @@ -164,10 +177,11 @@ minetest.register_node("vines:willow_rotten", { paramtype = "light", drop = "", paramtype2 = "wallmounted", + buildable_to = true, tile_images = { "vines_willow_rotten.png" }, drawtype = "signlike", inventory_image = "vines_willow.png", - groups = {snappy = 3,flammable=2, hanging_node=1}, + groups = {snappy = 3,flammable=2, hanging_node=1,vines_cleanup=1}, sounds = default.node_sound_leaves_defaults(), selection_box = { type = "wallmounted", @@ -180,10 +194,11 @@ minetest.register_node("vines:root", { climbable = true, sunlight_propagates = true, paramtype = "light", + buildable_to = true, tile_images = { "vines_root.png" }, drawtype = "plantlike", inventory_image = "vines_root.png", - groups = {vines=1,snappy = 3,flammable=2, hanging_node=1}, + groups = {vines=1,snappy = 3,flammable=2, hanging_node=1,vines_cleanup=1}, sounds = default.node_sound_leaves_defaults(), selection_box = { type = "fixed", @@ -198,6 +213,7 @@ minetest.register_node("vines:vine", { sunlight_propagates = true, drop = "", paramtype = "light", + buildable_to = true, tile_images = { "vines_vine.png" }, drawtype = "plantlike", inventory_image = "vines_vine.png", @@ -225,10 +241,11 @@ minetest.register_node("vines:vine_rotten", { drop = "", sunlight_propagates = true, paramtype = "light", + buildable_to = true, tile_images = { "vines_vine_rotten.png" }, drawtype = "plantlike", inventory_image = "vines_vine_rotten.png", - groups = {snappy = 3,flammable=2, hanging_node=1}, + groups = {snappy = 3,flammable=2, hanging_node=1,vines_cleanup=1}, sounds = default.node_sound_leaves_defaults(), selection_box = { type = "fixed", @@ -236,33 +253,54 @@ minetest.register_node("vines:vine_rotten", { }, }) ---ABM +-- vine rotting + minetest.register_abm({ nodenames = {"vines:vine", "vines:side", "vines:willow"}, - interval = 300, - chance = 8, + interval = vines.rot_interval, + chance = vines.rot_chance, action = function(pos, node, active_object_count, active_object_count_wider) if minetest.find_node_near(pos, 5, "group:tree") == nil then - walldir = node.param2 + local walldir = node.param2 minetest.add_node(pos, {name=node.name.."_rotten", param2 = walldir}) end end }) +-- vine growth + minetest.register_abm({ nodenames = {"vines:vine", "vines:side", "vines:willow"}, - interval = 300, - chance = 2, + interval = vines.growth_interval, + chance = vines.growth_chance, action = function(pos, node, active_object_count, active_object_count_wider) local p = {x=pos.x, y=pos.y-1, z=pos.z} local n = minetest.get_node(p) if n.name == "air" then - walldir = node.param2 + local walldir = node.param2 minetest.add_node(p, {name=node.name, param2 = walldir}) end end }) +-- cleanup if the initial tree is missing entirely (e.g. has been dug away) + +minetest.register_abm({ + nodenames = {"group:vines_cleanup"}, + interval = 10, + chance = 5, + action = function(pos, node, active_object_count, active_object_count_wider) + if not minetest.find_node_near(pos, 1, jungle_leaves_list) then + local p_top = {x=pos.x, y=pos.y+1, z=pos.z} + if minetest.get_item_group(minetest.get_node(p_top).name, "vines_cleanup") == 0 then + minetest.remove_node(pos) + end + end + end +}) + +-- rope extension + minetest.register_abm({ nodenames = {"vines:rope_end"}, interval = 1, @@ -310,12 +348,10 @@ plantslib:spawn_on_surfaces({ spawn_delay = spawn_interval, spawn_plants = {"vines:side"}, spawn_chance = 10, - spawn_surfaces = {"group:leafdecay"}, + spawn_surfaces = jungle_leaves_list, spawn_on_side = true, - near_nodes = {"default:water_source", "default:jungletree"}, - near_nodes_size = 10, - near_nodes_vertical = 5, - near_nodes_count = 1, + near_nodes = {"default:jungletree"}, + near_nodes_size = 5, plantlife_limit = -0.9, }) diff --git a/textures/new/bottomvine.png b/textures/new/bottomvine.png index c92bb85..49f88c0 100644 Binary files a/textures/new/bottomvine.png and b/textures/new/bottomvine.png differ diff --git a/textures/new/sidevine.png b/textures/new/sidevine.png index 4245711..fdeaeae 100644 Binary files a/textures/new/sidevine.png and b/textures/new/sidevine.png differ diff --git a/textures/new/vinesdead.png b/textures/new/vinesdead.png index d001ec9..3ac6ea5 100644 Binary files a/textures/new/vinesdead.png and b/textures/new/vinesdead.png differ diff --git a/textures/new/vineslive.png b/textures/new/vineslive.png index 6ba42b5..8afffe8 100644 Binary files a/textures/new/vineslive.png and b/textures/new/vineslive.png differ diff --git a/textures/old/vines_vine2.png b/textures/old/vines_vine2.png index b938f4b..c755da9 100644 Binary files a/textures/old/vines_vine2.png and b/textures/old/vines_vine2.png differ diff --git a/textures/old/vines_vine_rotten2.png b/textures/old/vines_vine_rotten2.png index 11b5474..c66e12e 100644 Binary files a/textures/old/vines_vine_rotten2.png and b/textures/old/vines_vine_rotten2.png differ diff --git a/textures/shears.png b/textures/shears.png index f15024c..c4c39f9 100644 Binary files a/textures/shears.png and b/textures/shears.png differ diff --git a/textures/vines_item.png b/textures/vines_item.png index f02bc65..c66242e 100644 Binary files a/textures/vines_item.png and b/textures/vines_item.png differ diff --git a/textures/vines_root.png b/textures/vines_root.png index c92bb85..49f88c0 100644 Binary files a/textures/vines_root.png and b/textures/vines_root.png differ diff --git a/textures/vines_rope.png b/textures/vines_rope.png index 525bc66..0045c4c 100644 Binary files a/textures/vines_rope.png and b/textures/vines_rope.png differ diff --git a/textures/vines_rope_end.png b/textures/vines_rope_end.png index a95048a..faf2c71 100644 Binary files a/textures/vines_rope_end.png and b/textures/vines_rope_end.png differ diff --git a/textures/vines_side.png b/textures/vines_side.png index 4245711..fdeaeae 100644 Binary files a/textures/vines_side.png and b/textures/vines_side.png differ diff --git a/textures/vines_side_rotten.png b/textures/vines_side_rotten.png index 87e4360..2576e93 100644 Binary files a/textures/vines_side_rotten.png and b/textures/vines_side_rotten.png differ diff --git a/textures/vines_vine.png b/textures/vines_vine.png index 6ba42b5..8afffe8 100644 Binary files a/textures/vines_vine.png and b/textures/vines_vine.png differ diff --git a/textures/vines_vine_rotten.png b/textures/vines_vine_rotten.png index d001ec9..3ac6ea5 100644 Binary files a/textures/vines_vine_rotten.png and b/textures/vines_vine_rotten.png differ diff --git a/textures/vines_willow.png b/textures/vines_willow.png index 91f8fef..ca0b831 100644 Binary files a/textures/vines_willow.png and b/textures/vines_willow.png differ diff --git a/textures/vines_willow_rotten.png b/textures/vines_willow_rotten.png index a8f4342..3c0622f 100644 Binary files a/textures/vines_willow_rotten.png and b/textures/vines_willow_rotten.png differ