From e973c4df4889cb52178d22b8458d9010c7dc2264 Mon Sep 17 00:00:00 2001 From: bas080 Date: Fri, 13 Feb 2015 03:10:15 +0100 Subject: [PATCH] Groups for spawning vines - Easily lets vines spawn on nodes that have the unique vine group name - Updated README.md that explains the groups spawning feature. - Made groups variable local to the registration function and not part of the namespace --- README.md | 13 +++++++++++-- functions.lua | 10 +++++++--- init.lua | 2 -- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b5ce524..7b54515 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,20 @@ - Jungle vines that spawn on the side of jungletrees ## API -The API is very minimal. It allows the registering of vines. +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 you +would like to spawn on by adding to the node it's group one of the following. + + + + 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. +drawtype. The type is determined by the spawn_on_side property in the biome +table. ### Example *taken from mod* diff --git a/functions.lua b/functions.lua index 5b946e8..ec0eba9 100644 --- a/functions.lua +++ b/functions.lua @@ -3,6 +3,11 @@ vines.register_vine = function( name, defs, biome ) local drop_node = 'vines:'..name local drawtype = '' local selection_box + local groups = { vines=1, snappy=3, flammable=2 } + + local group_name = name..'_vines' + biome.spawn_surfaces[ #biome.spawn_surfaces ] = group_name + if ( biome.spawn_on_side ) then selection_box = { type = "wallmounted", @@ -31,7 +36,7 @@ vines.register_vine = function( name, defs, biome ) tile_images = { "vines_"..name..".png" }, drawtype = drawtype, inventory_image = "vines_"..name..".png", - groups = vines.groups, + groups = groups, sounds = default.node_sound_leaves_defaults(), selection_box = selection_box, on_construct = function( pos ) @@ -71,7 +76,7 @@ vines.register_vine = function( name, defs, biome ) wield_image = "vines_"..name..".png", drawtype = drawtype, inventory_image = "vines_"..name..".png", - groups = vines.groups, + groups = groups, sounds = default.node_sound_leaves_defaults(), selection_box = selection_box, on_destruct = function( pos ) @@ -94,7 +99,6 @@ vines.register_vine = function( name, defs, biome ) local node = nodes[ index ] if index > #nodes then return registered end if minetest.registered_nodes[node] then - print('overiding: '..node) minetest.override_item( node, defs ) registered[#registered+1] = node end diff --git a/init.lua b/init.lua index 3876fbb..5a32412 100644 --- a/init.lua +++ b/init.lua @@ -1,6 +1,5 @@ vines = { name = 'vines', - groups = { vines=1, snappy=3, flammable=2 }, recipes = {} } @@ -10,6 +9,5 @@ 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" ) -dofile( minetest.get_modpath( vines.name ) .. "/spawning.lua" ) print("[Vines] Loaded!")