summaryrefslogtreecommitdiff
path: root/vines
diff options
context:
space:
mode:
Diffstat (limited to 'vines')
-rw-r--r--vines/LICENSE.md4
-rw-r--r--vines/README.md56
-rw-r--r--vines/aliases.lua11
-rw-r--r--vines/crafts.lua14
-rw-r--r--vines/depends.txt3
-rw-r--r--vines/functions.lua132
-rw-r--r--vines/init.lua14
-rw-r--r--vines/nodes.lua83
-rw-r--r--vines/recipes.lua12
-rw-r--r--vines/shear.lua15
-rw-r--r--vines/textures/vines_item.pngbin0 -> 167 bytes
-rw-r--r--vines/textures/vines_jungle_end.pngbin0 -> 497 bytes
-rw-r--r--vines/textures/vines_jungle_middle.pngbin0 -> 481 bytes
-rw-r--r--vines/textures/vines_root_end.pngbin0 -> 215 bytes
-rw-r--r--vines/textures/vines_root_middle.pngbin0 -> 201 bytes
-rw-r--r--vines/textures/vines_rope.pngbin0 -> 106 bytes
-rw-r--r--vines/textures/vines_rope_end.pngbin0 -> 118 bytes
-rw-r--r--vines/textures/vines_shears.pngbin0 -> 194 bytes
-rw-r--r--vines/textures/vines_side_end.pngbin0 -> 247 bytes
-rw-r--r--vines/textures/vines_side_middle.pngbin0 -> 225 bytes
-rw-r--r--vines/textures/vines_vine_end.pngbin0 -> 364 bytes
-rw-r--r--vines/textures/vines_vine_middle.pngbin0 -> 187 bytes
-rw-r--r--vines/textures/vines_willow_end.pngbin0 -> 226 bytes
-rw-r--r--vines/textures/vines_willow_middle.pngbin0 -> 196 bytes
-rw-r--r--vines/vines.lua104
25 files changed, 448 insertions, 0 deletions
diff --git a/vines/LICENSE.md b/vines/LICENSE.md
new file mode 100644
index 0000000..fb67788
--- /dev/null
+++ b/vines/LICENSE.md
@@ -0,0 +1,4 @@
+License
+=======
+- Code WTFPL
+- Texture CC
diff --git a/vines/README.md b/vines/README.md
new file mode 100644
index 0000000..386dcae
--- /dev/null
+++ b/vines/README.md
@@ -0,0 +1,56 @@
+# Vines
+
+## Features
+- Rope block for spawning rope that slowly drops into the deep.
+- Vines are climbable and slowly grow downward.
+- Shears that allow the collecting of vines.
+- Spawns vines on jungletree leaves.
+- Roots on the bottom of dirt and dirt with grass nodes.
+- Spawns vines on trees located in swampy area.
+- Jungle vines that spawn on the side of jungletrees
+
+## API
+The API is very minimal. It allows the registering of vines and the spawning of
+existing vines on nodes of your own.
+
+If you want vines to spawn on a certain node then you can choose which vine by
+adding to the node groups the unique group of that vine. This is determined by
+the name of the vine ( see vines.lua ) appended with '_vines'.
+An example would be.
+
+"willow_vines" or "jungle_vines"
+
+There are two types of vines. One that spawns at the bottom of nodes and uses the
+plantlike drawtype, and vines that spawn on the side that use signlike
+drawtype. The type is determined by the spawn_on_side property in the biome
+table.
+
+### Example
+*taken from mod*
+
+```lua
+
+ vines.register_vine( name, definitions, biome )
+
+ --e.g.
+
+ vines.register_vine( 'vine', {
+ description = "Vines",
+ average_length = 9
+ }, biome )
+
+```
+
+### definitions
+|key| type| description|
+|---| ---| ---|
+|description| string|The vine's tooltip description|
+|average_length|int| The average length of vines|
+
+For biome definitions please see the [biome_lib API documentation](https://github.com/VanessaE/biome_lib/blob/master/API.txt)
+
+## Notice
+Vines use after_destruct on registered leave nodes to remove vines from which
+the leaves are removed. This is done by using the override function.
+Malfunctions may occur if other mods override the after_destruct of these nodes
+also.
diff --git a/vines/aliases.lua b/vines/aliases.lua
new file mode 100644
index 0000000..fce7218
--- /dev/null
+++ b/vines/aliases.lua
@@ -0,0 +1,11 @@
+-- used to remove the old vine nodes. This gives room for the new nodes
+minetest.register_alias( 'vines:root', 'air' )
+minetest.register_alias( 'vines:root_rotten', 'air' )
+minetest.register_alias( 'vines:vine', 'air' )
+minetest.register_alias( 'vines:vine_rotten', 'air' )
+minetest.register_alias( 'vines:side', 'air' )
+minetest.register_alias( 'vines:side_rotten', 'air' )
+minetest.register_alias( 'vines:jungle', 'air' )
+minetest.register_alias( 'vines:jungle_rotten', 'air' )
+minetest.register_alias( 'vines:willow', 'air' )
+minetest.register_alias( 'vines:willow_rotten', 'air' )
diff --git a/vines/crafts.lua b/vines/crafts.lua
new file mode 100644
index 0000000..19e658b
--- /dev/null
+++ b/vines/crafts.lua
@@ -0,0 +1,14 @@
+minetest.register_craft({
+ output = 'vines:rope_block',
+ recipe = vines.recipes['rope_block']
+})
+
+minetest.register_craft({
+ output = 'vines:shears',
+ recipe = vines.recipes['shears']
+})
+
+minetest.register_craftitem("vines:vines", {
+ description = "Vines",
+ inventory_image = "vines_item.png",
+})
diff --git a/vines/depends.txt b/vines/depends.txt
new file mode 100644
index 0000000..573e6e1
--- /dev/null
+++ b/vines/depends.txt
@@ -0,0 +1,3 @@
+default
+biome_lib
+moretrees?
diff --git a/vines/functions.lua b/vines/functions.lua
new file mode 100644
index 0000000..db120a6
--- /dev/null
+++ b/vines/functions.lua
@@ -0,0 +1,132 @@
+vines.register_vine = function( name, defs, biome )
+ local biome = biome
+ local groups = { vines=1, snappy=3, flammable=2 }
+
+ local vine_name_end = 'vines:'..name..'_end'
+ local vine_name_middle = 'vines:'..name..'_middle'
+
+ local vine_image_end = "vines_"..name.."_end.png"
+ local vine_image_middle = "vines_"..name.."_middle.png"
+
+ local drop_node = vine_name_end
+
+ biome.spawn_plants = { vine_name_end }
+
+ local vine_group = 'group:'..name..'_vines'
+ biome.spawn_surfaces[ #biome.spawn_surfaces + 1 ] = vine_group
+
+ local selection_box = { type = "wallmounted", }
+ local drawtype = 'signlike'
+ if ( not biome.spawn_on_side ) then
+ --different properties for bottom and side vines.
+ selection_box = { type = "fixed", fixed = { -0.4, -1/2, -0.4, 0.4, 1/2, 0.4 }, }
+ drawtype = 'plantlike'
+ end
+
+ minetest.register_node( vine_name_end, {
+ description = defs.description,
+ walkable = false,
+ climbable = true,
+ wield_image = vine_image_end,
+ drop = "",
+ sunlight_propagates = true,
+ paramtype = "light",
+ paramtype2 = "wallmounted",
+ buildable_to = true,
+ tiles = { vine_image_end },
+ drawtype = drawtype,
+ inventory_image = vine_image_end,
+ groups = groups,
+ sounds = default.node_sound_leaves_defaults(),
+ selection_box = selection_box,
+ on_construct = function( pos )
+ local timer = minetest.get_node_timer( pos )
+ timer:start( math.random(5, 10) )
+ end,
+ on_timer = function( pos )
+ local node = minetest.get_node( pos )
+ local bottom = {x=pos.x, y=pos.y-1, z=pos.z}
+ local bottom_node = minetest.get_node( bottom )
+ if bottom_node.name == "air" then
+ if not ( math.random( defs.average_length ) == 1 ) then
+ minetest.set_node( pos, { name = vine_name_middle, param2 = node.param2 } )
+ minetest.set_node( bottom, { name = node.name, param2 = node.param2 } )
+ local timer = minetest.get_node_timer( bottom_node )
+ timer:start( math.random(5, 10) )
+ end
+ end
+ end,
+ after_dig_node = function(pos, node, oldmetadata, user)
+ vines.dig_vine( pos, drop_node, user )
+ end
+ })
+
+
+ minetest.register_node( vine_name_middle, {
+ description = "Matured "..defs.description,
+ walkable = false,
+ climbable = true,
+ drop = "",
+ sunlight_propagates = true,
+ paramtype = "light",
+ paramtype2 = "wallmounted",
+ buildable_to = true,
+ tiles = { vine_image_middle },
+ wield_image = vine_image_middle,
+ drawtype = drawtype,
+ inventory_image = vine_image_middle,
+ groups = groups,
+ sounds = default.node_sound_leaves_defaults(),
+ selection_box = selection_box,
+ on_destruct = function( pos )
+ local node = minetest.get_node( pos )
+ local bottom = {x=pos.x, y=pos.y-1, z=pos.z}
+ local bottom_node = minetest.get_node( bottom )
+ if minetest.get_item_group( bottom_node.name, "vines") then
+ minetest.remove_node( bottom )
+ end
+ end,
+ after_dig_node = function( pos, node, oldmetadata, user )
+ vines.dig_vine( pos, drop_node, user )
+ end
+ })
+
+ biome_lib:spawn_on_surfaces( biome )
+
+ local override_nodes = function( nodes, defs )
+ local function override( index, registered )
+ local node = nodes[ index ]
+ if index > #nodes then return registered end
+ if minetest.registered_nodes[node] then
+ minetest.override_item( node, defs )
+ registered[#registered+1] = node
+ end
+ override( index+1, registered )
+ end
+ override( 1, {} )
+ end
+
+ override_nodes( biome.spawn_surfaces,{
+ after_destruct = function( pos )
+ local pos_min = { x = pos.x -1, y = pos.y - 1, z = pos.z - 1 }
+ local pos_max = { x = pos.x +1, y = pos.y + 1, z = pos.z + 1 }
+ local positions = minetest.find_nodes_in_area( pos_min, pos_max, "group:vines" )
+ for index, position in pairs(positions) do
+ minetest.remove_node( position )
+ end
+ end
+ })
+
+end
+
+vines.dig_vine = function( pos, node_name, user )
+ --only dig give the vine if shears are used
+ if not user then return false end
+ local wielded = user:get_wielded_item()
+ if 'vines:shears' == wielded:get_name() then
+ local inv = user:get_inventory()
+ if inv then
+ inv:add_item("main", ItemStack( node_name ))
+ end
+ end
+end
diff --git a/vines/init.lua b/vines/init.lua
new file mode 100644
index 0000000..72eda93
--- /dev/null
+++ b/vines/init.lua
@@ -0,0 +1,14 @@
+vines = {
+ name = 'vines',
+ recipes = {}
+}
+
+dofile( minetest.get_modpath( vines.name ) .. "/functions.lua" )
+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 ) .. "/shear.lua" )
+dofile( minetest.get_modpath( vines.name ) .. "/vines.lua" )
+
+print("[Vines] Loaded!")
diff --git a/vines/nodes.lua b/vines/nodes.lua
new file mode 100644
index 0000000..9d7df00
--- /dev/null
+++ b/vines/nodes.lua
@@ -0,0 +1,83 @@
+minetest.register_node("vines:rope_block", {
+ description = "Rope",
+ sunlight_propagates = true,
+ paramtype = "light",
+ tiles = {
+ "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 = "",
+ tiles = { "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 = "",
+ tiles = { "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/vines/recipes.lua b/vines/recipes.lua
new file mode 100644
index 0000000..d2b928a
--- /dev/null
+++ b/vines/recipes.lua
@@ -0,0 +1,12 @@
+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/vines/shear.lua b/vines/shear.lua
new file mode 100644
index 0000000..e6d915a
--- /dev/null
+++ b/vines/shear.lua
@@ -0,0 +1,15 @@
+minetest.register_tool("vines:shears", {
+ description = "Shears",
+ inventory_image = "vines_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}
+ }
+ },
+})
diff --git a/vines/textures/vines_item.png b/vines/textures/vines_item.png
new file mode 100644
index 0000000..c66242e
--- /dev/null
+++ b/vines/textures/vines_item.png
Binary files differ
diff --git a/vines/textures/vines_jungle_end.png b/vines/textures/vines_jungle_end.png
new file mode 100644
index 0000000..6c8d339
--- /dev/null
+++ b/vines/textures/vines_jungle_end.png
Binary files differ
diff --git a/vines/textures/vines_jungle_middle.png b/vines/textures/vines_jungle_middle.png
new file mode 100644
index 0000000..bf838a5
--- /dev/null
+++ b/vines/textures/vines_jungle_middle.png
Binary files differ
diff --git a/vines/textures/vines_root_end.png b/vines/textures/vines_root_end.png
new file mode 100644
index 0000000..4fc3f87
--- /dev/null
+++ b/vines/textures/vines_root_end.png
Binary files differ
diff --git a/vines/textures/vines_root_middle.png b/vines/textures/vines_root_middle.png
new file mode 100644
index 0000000..49f88c0
--- /dev/null
+++ b/vines/textures/vines_root_middle.png
Binary files differ
diff --git a/vines/textures/vines_rope.png b/vines/textures/vines_rope.png
new file mode 100644
index 0000000..0045c4c
--- /dev/null
+++ b/vines/textures/vines_rope.png
Binary files differ
diff --git a/vines/textures/vines_rope_end.png b/vines/textures/vines_rope_end.png
new file mode 100644
index 0000000..faf2c71
--- /dev/null
+++ b/vines/textures/vines_rope_end.png
Binary files differ
diff --git a/vines/textures/vines_shears.png b/vines/textures/vines_shears.png
new file mode 100644
index 0000000..c4c39f9
--- /dev/null
+++ b/vines/textures/vines_shears.png
Binary files differ
diff --git a/vines/textures/vines_side_end.png b/vines/textures/vines_side_end.png
new file mode 100644
index 0000000..5b3b28f
--- /dev/null
+++ b/vines/textures/vines_side_end.png
Binary files differ
diff --git a/vines/textures/vines_side_middle.png b/vines/textures/vines_side_middle.png
new file mode 100644
index 0000000..2576e93
--- /dev/null
+++ b/vines/textures/vines_side_middle.png
Binary files differ
diff --git a/vines/textures/vines_vine_end.png b/vines/textures/vines_vine_end.png
new file mode 100644
index 0000000..062857b
--- /dev/null
+++ b/vines/textures/vines_vine_end.png
Binary files differ
diff --git a/vines/textures/vines_vine_middle.png b/vines/textures/vines_vine_middle.png
new file mode 100644
index 0000000..8afffe8
--- /dev/null
+++ b/vines/textures/vines_vine_middle.png
Binary files differ
diff --git a/vines/textures/vines_willow_end.png b/vines/textures/vines_willow_end.png
new file mode 100644
index 0000000..b5b8e59
--- /dev/null
+++ b/vines/textures/vines_willow_end.png
Binary files differ
diff --git a/vines/textures/vines_willow_middle.png b/vines/textures/vines_willow_middle.png
new file mode 100644
index 0000000..ca0b831
--- /dev/null
+++ b/vines/textures/vines_willow_middle.png
Binary files differ
diff --git a/vines/vines.lua b/vines/vines.lua
new file mode 100644
index 0000000..82c5b2a
--- /dev/null
+++ b/vines/vines.lua
@@ -0,0 +1,104 @@
+vines.register_vine( 'root', {
+ description = "Roots",
+ average_length = 9,
+},{
+ choose_random_wall = true,
+ avoid_nodes = {"vines:root_middle"},
+ avoid_radius = 5,
+ spawn_delay = 500,
+ spawn_chance = 10,
+ spawn_surfaces = {
+ "default:dirt_with_grass",
+ "default:dirt"
+ },
+ spawn_on_bottom = true,
+ plantlife_limit = -0.6,
+ humidity_min = 0.4,
+})
+
+vines.register_vine( 'vine', {
+ description = "Vines",
+ average_length = 5,
+},{
+ choose_random_wall = true,
+ avoid_nodes = {"group:vines"},
+ avoid_radius = 5,
+ spawn_delay = 500,
+ spawn_chance = 100,
+ spawn_surfaces = {
+ "default:jungleleaves",
+ "moretrees:jungletree_leaves_red",
+ "moretrees:jungletree_leaves_yellow",
+ "moretrees:jungletree_leaves_green"
+ },
+ spawn_on_bottom = true,
+ plantlife_limit = -0.9,
+ humidity_min = 0.7,
+})
+
+vines.register_vine( 'side', {
+ description = "Vines",
+ average_length = 6,
+},{
+ choose_random_wall = true,
+ avoid_nodes = {"group:vines", "default:apple"},
+ choose_random_wall = true,
+ avoid_radius = 3,
+ spawn_delay = 500,
+ spawn_chance = 100,
+ spawn_surfaces = {
+ "default:jungleleaves",
+ "moretrees:jungletree_leaves_red",
+ "moretrees:jungletree_leaves_yellow",
+ "moretrees:jungletree_leaves_green"
+ },
+ spawn_on_side = true,
+ plantlife_limit = -0.9,
+ humidity_min = 0.4,
+})
+
+vines.register_vine( "jungle", {
+ description = "Jungle Vines",
+ average_length = 7,
+},{
+ choose_random_wall = true,
+ neighbors = {
+ "default:jungleleaves",
+ "moretrees:jungletree_leaves_red",
+ "moretrees:jungletree_leaves_yellow",
+ "moretrees:jungletree_leaves_green"
+ },
+ avoid_nodes = {
+ "vines:jungle_middle",
+ "vines:jungle_end",
+ },
+ avoid_radius = 5,
+ spawn_delay = 500,
+ spawn_chance = 100,
+ spawn_surfaces = {
+ "default:jungletree",
+ "moretrees:jungletree_trunk"
+ },
+ spawn_on_side = true,
+ plantlife_limit = -0.9,
+ humidity_min = 0.2,
+})
+
+vines.register_vine( 'willow', {
+ description = "Willow Vines",
+ average_length = 9,
+},{
+ choose_random_wall = true,
+ avoid_nodes = { "vines:willow_middle" },
+ avoid_radius = 5,
+ near_nodes = { 'default:water_source' },
+ near_nodes_size = 1,
+ near_nodes_count = 1,
+ near_nodes_vertical = 7,
+ plantlife_limit = -0.8,
+ spawn_chance = 10,
+ spawn_delay = 500,
+ spawn_on_side = true,
+ spawn_surfaces = {"moretrees:willow_leaves"},
+ humidity_min = 0.5
+})