Add Pinetrees
This commit is contained in:
parent
49fa67c5e4
commit
068fa5c927
78
init.lua
78
init.lua
@ -199,6 +199,77 @@ function add_savannabush(data, a, x, y, z, minp, maxp, c_tree, c_leaves, pr)
|
||||
data[vi] = c_tree
|
||||
end
|
||||
|
||||
function add_pinetree(data, a, x, y, z, minp, maxp, c_tree, c_leaves, pr)
|
||||
th = pr:next(9, 13)
|
||||
for yy=math.max(minp.y, y), math.min(maxp.y, y+th) do
|
||||
local vi = a:index(x, yy, z)
|
||||
data[vi] = c_tree
|
||||
end
|
||||
maxy = y+th
|
||||
for xx=math.max(minp.x, x-3), math.min(maxp.x, x+3) do
|
||||
for yy=math.max(minp.y, maxy-1), math.min(maxp.y, maxy-1) do
|
||||
for zz=math.max(minp.z, z-3), math.min(maxp.z, z+3) do
|
||||
if pr:next(1, 100) < 80 then
|
||||
add_leaves(data, a:index(xx, yy, zz), c_leaves)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
for xx=math.max(minp.x, x-2), math.min(maxp.x, x+2) do
|
||||
for yy=math.max(minp.y, maxy), math.min(maxp.y, maxy) do
|
||||
for zz=math.max(minp.z, z-2), math.min(maxp.z, z+2) do
|
||||
if pr:next(1, 100) < 85 then
|
||||
add_leaves(data, a:index(xx, yy, zz), c_leaves)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
for xx=math.max(minp.x, x-1), math.min(maxp.x, x+1) do
|
||||
for yy=math.max(minp.y, maxy+1), math.min(maxp.y, maxy+1) do
|
||||
for zz=math.max(minp.z, z-1), math.min(maxp.z, z+1) do
|
||||
if pr:next(1, 100) < 90 then
|
||||
add_leaves(data, a:index(xx, yy, zz), c_leaves)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
add_leaves(data, a:index(x, maxy+1, z), c_leaves)
|
||||
my = 0
|
||||
for i=1,20 do
|
||||
xi = pr:next(x-3, x+2)
|
||||
yy = pr:next(maxy-6, maxy-5)
|
||||
zi = pr:next(z-3, z+2)
|
||||
if yy > my then
|
||||
my = yy
|
||||
end
|
||||
for xx=math.max(minp.x, xi), math.min(maxp.x, xi+1) do
|
||||
for zz=math.max(minp.z, zi), math.min(maxp.z, zi+1) do
|
||||
if minp.y<=yy and maxp.y>=yy then
|
||||
add_leaves(data, a:index(xx, yy, zz), c_leaves)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
for xx=math.max(minp.x, x-2), math.min(maxp.x, x+2) do
|
||||
for yy=math.max(minp.y, my+1), math.min(maxp.y, my+1) do
|
||||
for zz=math.max(minp.z, z-2), math.min(maxp.z, z+2) do
|
||||
if pr:next(1, 100) < 85 then
|
||||
add_leaves(data, a:index(xx, yy, zz), c_leaves)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
for xx=math.max(minp.x, x-1), math.min(maxp.x, x+1) do
|
||||
for yy=math.max(minp.y, my+2), math.min(maxp.y, my+2) do
|
||||
for zz=math.max(minp.z, z-1), math.min(maxp.z, z+1) do
|
||||
if pr:next(1, 100) < 90 then
|
||||
add_leaves(data, a:index(xx, yy, zz), c_leaves)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/nodes.lua")
|
||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/buildings.lua")
|
||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/villages.lua")
|
||||
@ -289,6 +360,9 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||
local c_savannasapling = minetest.get_content_id("mg:savannasapling")
|
||||
local c_savannatree = minetest.get_content_id("mg:savannatree")
|
||||
local c_savannaleaves = minetest.get_content_id("mg:savannaleaves")
|
||||
local c_pinesapling = minetest.get_content_id("mg:pinesapling")
|
||||
local c_pinetree = minetest.get_content_id("mg:pinetree")
|
||||
local c_pineleaves = minetest.get_content_id("mg:pineleaves")
|
||||
local c_dirt = minetest.get_content_id("default:dirt")
|
||||
local c_stone = minetest.get_content_id("default:stone")
|
||||
local c_water = minetest.get_content_id("default:water_source")
|
||||
@ -456,6 +530,10 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||
if not in_village then
|
||||
add_savannabush(data, a, x, y+1, z, treemin, treemax, c_savannatree, c_savannaleaves, pr)
|
||||
end
|
||||
elseif above_top == c_pinesapling then
|
||||
if not in_village then
|
||||
add_pinetree(data, a, x, y+1, z, treemin, treemax, c_pinetree, c_pineleaves, pr)
|
||||
end
|
||||
elseif above_top == c_cactus then
|
||||
if not in_village then
|
||||
ch = pr:next(1, 4)
|
||||
|
72
nodes.lua
72
nodes.lua
@ -28,7 +28,7 @@ minetest.register_node("mg:savannaleaves", {
|
||||
})
|
||||
|
||||
minetest.register_node("mg:savannasapling", {
|
||||
description = "Jungle Sapling",
|
||||
description = "Savanna Sapling",
|
||||
drawtype = "plantlike",
|
||||
visual_scale = 1.0,
|
||||
tiles = {"mg_dry_sapling.png"},
|
||||
@ -72,9 +72,79 @@ minetest.register_node("mg:dirt_with_dry_grass", {
|
||||
}),
|
||||
})
|
||||
|
||||
minetest.register_node("mg:pinetree", {
|
||||
description = "Pine Tree",
|
||||
tiles = {"mg_pine_tree_top.png", "mg_pine_tree_top.png", "mg_pine_tree.png"},
|
||||
groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("mg:pineleaves", {
|
||||
description = "Pine Leaves",
|
||||
drawtype = "allfaces_optional",
|
||||
visual_scale = 1.3,
|
||||
tiles = {"mg_pine_leaves.png"},
|
||||
paramtype = "light",
|
||||
groups = {snappy=3, leafdecay=3, flammable=2, leaves=1},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
{
|
||||
items = {'mg:pinesapling'},
|
||||
rarity = 20,
|
||||
},
|
||||
{
|
||||
items = {'mg:pineleaves'},
|
||||
}
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("mg:pinesapling", {
|
||||
description = "Pine Sapling",
|
||||
drawtype = "plantlike",
|
||||
visual_scale = 1.0,
|
||||
tiles = {"mg_pine_sapling.png"},
|
||||
inventory_image = "mg_pine_sapling.png",
|
||||
wield_image = "mg_pine_sapling.png",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
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_abm({
|
||||
nodenames = {"mg:pinesapling"},
|
||||
interval = 10,
|
||||
chance = 50,
|
||||
action = function(pos, node)
|
||||
local vm = minetest.get_voxel_manip()
|
||||
local minp, maxp = vm:read_from_map({x=pos.x-10, y=pos.y, z=pos.z-10}, {x=pos.x+10, y=pos.y+20, z=pos.z+10})
|
||||
local a = VoxelArea:new{MinEdge=minp, MaxEdge=maxp}
|
||||
local data = vm:get_data()
|
||||
local c_tree = minetest.get_content_id("mg:pinetree")
|
||||
local c_leaves = minetest.get_content_id("mg:pineleaves")
|
||||
add_pinetree(data, a, pos.x, pos.y, pos.z, minp, maxp, c_tree, c_leaves, PseudoRandom(math.random(1,100000)))
|
||||
vm:set_data(data)
|
||||
vm:write_to_map(data)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:wood 4',
|
||||
recipe = {
|
||||
{'default:savannatree'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:wood 4',
|
||||
recipe = {
|
||||
{'default:pinetree'},
|
||||
}
|
||||
})
|
||||
|
BIN
textures/mg_pine_leaves.png
Normal file
BIN
textures/mg_pine_leaves.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 428 B |
BIN
textures/mg_pine_sapling.png
Normal file
BIN
textures/mg_pine_sapling.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 290 B |
BIN
textures/mg_pine_tree.png
Normal file
BIN
textures/mg_pine_tree.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 490 B |
BIN
textures/mg_pine_tree_top.png
Normal file
BIN
textures/mg_pine_tree_top.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 738 B |
Loading…
x
Reference in New Issue
Block a user