Added saplings and related ABMs

Acacia, Pine, and Golden tree saplings added.  Made texture of heaven
grass swappable in the nodes.lua file.
This commit is contained in:
Chris N 2014-07-28 15:43:03 -10:00
parent 7af3e34b50
commit c1761c0eb0
5 changed files with 198 additions and 11 deletions

View File

@ -193,4 +193,75 @@ minetest.register_abm({
minetest.set_node(pos, {name = "default:dirt"})
end
end
})
--SAPLING GROWTH--
-- Pine sapling
minetest.register_abm({
nodenames = {"skylands:pine_sapling"},
interval = 59,
chance = 3,
action = function(pos, node)
local x = pos.x
local y = pos.y
local z = pos.z
local vm = minetest.get_voxel_manip()
local pos1 = {x=x-2, y=y-4, z=z-2}
local pos2 = {x=x+2, y=y+17, z=z+2}
local emin, emax = vm:read_from_map(pos1, pos2)
local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax})
local data = vm:get_data()
skylands:pinetree(x, y, z, area, data)
vm:set_data(data)
vm:write_to_map()
vm:update_map()
end,
})
-- Acacia sapling
minetest.register_abm({
nodenames = {"skylands:acacia_sapling"},
interval = 61,
chance = 3,
action = function(pos, node)
local x = pos.x
local y = pos.y
local z = pos.z
local vm = minetest.get_voxel_manip()
local pos1 = {x=x-4, y=y-3, z=z-4}
local pos2 = {x=x+4, y=y+6, z=z+4}
local emin, emax = vm:read_from_map(pos1, pos2)
local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax})
local data = vm:get_data()
skylands:acaciatree(x, y, z, area, data)
vm:set_data(data)
vm:write_to_map()
vm:update_map()
end,
})
-- Golden Tree sapling
minetest.register_abm({
nodenames = {"skylands:golden_sapling"},
interval = 61,
chance = 3,
action = function(pos, node)
local x = pos.x
local y = pos.y
local z = pos.z
local vm = minetest.get_voxel_manip()
local pos1 = {x=x-4, y=y-3, z=z-4}
local pos2 = {x=x+4, y=y+6, z=z+4}
local emin, emax = vm:read_from_map(pos1, pos2)
local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax})
local data = vm:get_data()
skylands:goldentree(x, y, z, area, data)
vm:set_data(data)
vm:write_to_map()
vm:update_map()
end,
})

138
nodes.lua
View File

@ -1,5 +1,7 @@
-- Nodes
local OLDSTYLE = false --variable to toggle color of heavengrass
-- REDEFINITIONS --
minetest.register_node("skylands:stone", {
@ -75,17 +77,31 @@ minetest.register_craft({
}
})
--gold heaven grass for heaven biome... rich soil
minetest.register_node("skylands:heaven_grass", {
description = "Dirt with Heaven Grass",
tiles = {"skylands_heavengrass2.png", "skylands_rich_dirt.png", "skylands_rich_dirt.png^skylands_heavengrass_side2.png"},
is_ground_content = true,
groups = {crumbly=3,soil=1},
drop = 'skylands:rich_dirt',
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.25},
}),
})
if OLDSTYLE == true then
--gold heaven grass for heaven biome... rich soil
minetest.register_node("skylands:heaven_grass", {
description = "Dirt with Heaven Grass",
tiles = {"skylands_heavengrass.png", "default_dirt.png", "default_dirt.png^skylands_heavengrass_side.png"},
is_ground_content = true,
groups = {crumbly=3,soil=1},
drop = 'skylands:rich_dirt',
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.25},
}),
})
else
--gold heaven grass for heaven biome... rich soil
minetest.register_node("skylands:heaven_grass", {
description = "Dirt with Heaven Grass",
tiles = {"skylands_heavengrass2.png", "skylands_rich_dirt.png", "skylands_rich_dirt.png^skylands_heavengrass_side2.png"},
is_ground_content = true,
groups = {crumbly=3,soil=1},
drop = 'skylands:rich_dirt',
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.25},
}),
})
end
minetest.register_node("skylands:rich_dirt", {
description = "Rich Dirt",
@ -105,6 +121,21 @@ minetest.register_node("skylands:golden_leaves", {
paramtype = "light",
is_ground_content = false,
groups = {snappy=3, leafdecay=3, flammable=2, leaves=1},
drop = {
max_items = 1,
items = {
{
-- player will get sapling with 1/20 chance
items = {'skylands:golden_sapling'},
rarity = 20,
},
{
-- player will get leaves only if he get no saplings,
-- this is because max_items is 1
items = {'skylands:golden_leaves'},
}
}
},
sounds = default.node_sound_leaves_defaults(),
})
@ -343,6 +374,21 @@ minetest.register_node("skylands:acacialeaf", {
paramtype = "light",
is_ground_content = false,
groups = {snappy=3, flammable=2, leaves=1},
drop = {
max_items = 1,
items = {
{
-- player will get sapling with 1/20 chance
items = {'skylands:acacia_sapling'},
rarity = 20,
},
{
-- player will get leaves only if he get no saplings,
-- this is because max_items is 1
items = {'skylands:acacialeaf'},
}
}
},
sounds = default.node_sound_leaves_defaults(),
})
@ -364,6 +410,21 @@ minetest.register_node("skylands:needles", {
paramtype = "light",
is_ground_content = false,
groups = {snappy=3},
drop = {
max_items = 1,
items = {
{
-- player will get sapling with 1/20 chance
items = {'skylands:pine_sapling'},
rarity = 20,
},
{
-- player will get leaves only if he get no saplings,
-- this is because max_items is 1
items = {'skylands:needles'},
}
}
},
sounds = default.node_sound_leaves_defaults(),
})
@ -558,3 +619,58 @@ minetest.register_node("skylands:spring", {
groups = {water=3, liquid=3, puts_out_fire=1, freezes=1},
})
--SAPLINGS--
minetest.register_node("skylands:pine_sapling", {
description = "Pine Sapling",
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"skylands_pine_sapling.png"},
inventory_image = "skylands_pine_sapling.png",
wield_image = "skylands_pine_sapling.png",
paramtype = "light",
walkable = false,
is_ground_content = true,
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
},
groups = {snappy=2,dig_immediate=3,flammable=2,attached_node=1},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("skylands:acacia_sapling", {
description = "Acacia Sapling",
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"skylands_acacia_sapling.png"},
inventory_image = "skylands_acacia_sapling.png",
wield_image = "skylands_acacia_sapling.png",
paramtype = "light",
walkable = false,
is_ground_content = true,
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
},
groups = {snappy=2,dig_immediate=3,flammable=2,attached_node=1},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("skylands:golden_sapling", {
description = "Golden Tree Sapling",
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"skylands_golden_sapling.png"},
inventory_image = "skylands_golden_sapling.png",
wield_image = "skylands_golden_sapling.png",
paramtype = "light",
walkable = false,
is_ground_content = true,
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
},
groups = {snappy=2,dig_immediate=3,flammable=2,attached_node=1},
sounds = default.node_sound_leaves_defaults(),
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B