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
master
bas080 2015-02-13 03:10:15 +01:00
parent 1d71ba447b
commit e973c4df48
3 changed files with 18 additions and 7 deletions

View File

@ -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*

View File

@ -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

View File

@ -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!")