mirror of
https://github.com/minetest-mods/ropes.git
synced 2024-11-24 16:33:48 +01:00
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
This commit is contained in:
parent
1d71ba447b
commit
e973c4df48
13
README.md
13
README.md
@ -10,11 +10,20 @@
|
|||||||
- Jungle vines that spawn on the side of jungletrees
|
- Jungle vines that spawn on the side of jungletrees
|
||||||
|
|
||||||
## API
|
## 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
|
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
|
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
|
### Example
|
||||||
*taken from mod*
|
*taken from mod*
|
||||||
|
@ -3,6 +3,11 @@ vines.register_vine = function( name, defs, biome )
|
|||||||
local drop_node = 'vines:'..name
|
local drop_node = 'vines:'..name
|
||||||
local drawtype = ''
|
local drawtype = ''
|
||||||
local selection_box
|
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
|
if ( biome.spawn_on_side ) then
|
||||||
selection_box = {
|
selection_box = {
|
||||||
type = "wallmounted",
|
type = "wallmounted",
|
||||||
@ -31,7 +36,7 @@ vines.register_vine = function( name, defs, biome )
|
|||||||
tile_images = { "vines_"..name..".png" },
|
tile_images = { "vines_"..name..".png" },
|
||||||
drawtype = drawtype,
|
drawtype = drawtype,
|
||||||
inventory_image = "vines_"..name..".png",
|
inventory_image = "vines_"..name..".png",
|
||||||
groups = vines.groups,
|
groups = groups,
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
sounds = default.node_sound_leaves_defaults(),
|
||||||
selection_box = selection_box,
|
selection_box = selection_box,
|
||||||
on_construct = function( pos )
|
on_construct = function( pos )
|
||||||
@ -71,7 +76,7 @@ vines.register_vine = function( name, defs, biome )
|
|||||||
wield_image = "vines_"..name..".png",
|
wield_image = "vines_"..name..".png",
|
||||||
drawtype = drawtype,
|
drawtype = drawtype,
|
||||||
inventory_image = "vines_"..name..".png",
|
inventory_image = "vines_"..name..".png",
|
||||||
groups = vines.groups,
|
groups = groups,
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
sounds = default.node_sound_leaves_defaults(),
|
||||||
selection_box = selection_box,
|
selection_box = selection_box,
|
||||||
on_destruct = function( pos )
|
on_destruct = function( pos )
|
||||||
@ -94,7 +99,6 @@ vines.register_vine = function( name, defs, biome )
|
|||||||
local node = nodes[ index ]
|
local node = nodes[ index ]
|
||||||
if index > #nodes then return registered end
|
if index > #nodes then return registered end
|
||||||
if minetest.registered_nodes[node] then
|
if minetest.registered_nodes[node] then
|
||||||
print('overiding: '..node)
|
|
||||||
minetest.override_item( node, defs )
|
minetest.override_item( node, defs )
|
||||||
registered[#registered+1] = node
|
registered[#registered+1] = node
|
||||||
end
|
end
|
||||||
|
2
init.lua
2
init.lua
@ -1,6 +1,5 @@
|
|||||||
vines = {
|
vines = {
|
||||||
name = 'vines',
|
name = 'vines',
|
||||||
groups = { vines=1, snappy=3, flammable=2 },
|
|
||||||
recipes = {}
|
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 ) .. "/nodes.lua" )
|
||||||
dofile( minetest.get_modpath( vines.name ) .. "/shear.lua" )
|
dofile( minetest.get_modpath( vines.name ) .. "/shear.lua" )
|
||||||
dofile( minetest.get_modpath( vines.name ) .. "/vines.lua" )
|
dofile( minetest.get_modpath( vines.name ) .. "/vines.lua" )
|
||||||
dofile( minetest.get_modpath( vines.name ) .. "/spawning.lua" )
|
|
||||||
|
|
||||||
print("[Vines] Loaded!")
|
print("[Vines] Loaded!")
|
||||||
|
Loading…
Reference in New Issue
Block a user