Compare commits
5 Commits
ec16b9b322
...
ae5b7f33e2
Author | SHA1 | Date |
---|---|---|
|
ae5b7f33e2 | |
|
399453c00f | |
|
25522d8843 | |
|
6cc546b218 | |
|
e5a9b76e25 |
|
@ -1,8 +1,9 @@
|
||||||
|
```
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
--
|
--
|
||||||
-- CONIFERS MOD
|
-- CONIFERS MOD
|
||||||
-- For Minetest
|
-- For Minetest
|
||||||
-- Created by Cisoun (cysoun[at]gmail.com).
|
-- Created originally by Cisoun (cysoun[at]gmail.com).
|
||||||
--
|
--
|
||||||
-- This mod adds some conifers randomly at a certain altitude.
|
-- This mod adds some conifers randomly at a certain altitude.
|
||||||
-- There are two types of conifers: regular and narrow.
|
-- There are two types of conifers: regular and narrow.
|
||||||
|
@ -10,7 +11,10 @@
|
||||||
-- choose if you want to keep normal trees above this altitude.
|
-- choose if you want to keep normal trees above this altitude.
|
||||||
--
|
--
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
```
|
||||||
|
|
||||||
|
For a description of this mod, see
|
||||||
|
https://forum.minetest.net/viewtopic.php?f=9&t=10268&p=156575.
|
||||||
|
|
||||||
TODO:
|
TODO:
|
||||||
— add a TODO list
|
* Move settings to settingtypes.txt
|
21
init.lua
21
init.lua
|
@ -256,7 +256,7 @@ function conifers:is_node_in_cube(nodenames, pos, size)
|
||||||
for x = pos.x-size, pos.x+size do
|
for x = pos.x-size, pos.x+size do
|
||||||
for y = pos.y-hs, pos.y+hs do
|
for y = pos.y-hs, pos.y+hs do
|
||||||
for z = pos.z-size, pos.z+size do
|
for z = pos.z-size, pos.z+size do
|
||||||
local n = minetest.get_node_or_nil({x=x, y=y, z=z})
|
local n = minetest.get_node_or_nil{x=x, y=y, z=z}
|
||||||
if n == nil
|
if n == nil
|
||||||
or n.name == "ignore"
|
or n.name == "ignore"
|
||||||
or conifers:table_contains(nodenames, n.name) then
|
or conifers:table_contains(nodenames, n.name) then
|
||||||
|
@ -419,12 +419,12 @@ function conifers:make_conifer(pos, conifer_type)
|
||||||
nodes = manip:get_data()
|
nodes = manip:get_data()
|
||||||
|
|
||||||
-- Check if we can gros a conifer at this place.
|
-- Check if we can gros a conifer at this place.
|
||||||
local p_pos = area:index(pos.x, pos.y, pos.z)
|
local vi = area:indexp(pos)
|
||||||
local d_p_pos = nodes[p_pos]
|
local id = nodes[vi]
|
||||||
|
|
||||||
if nodes[area:index(pos.x, pos.y-1, pos.z)] ~= conifers_c_dirt_with_grass
|
if nodes[vi - area.ystride] ~= conifers_c_dirt_with_grass
|
||||||
and (d_p_pos ~= conifers_c_air
|
and (id ~= conifers_c_air
|
||||||
or d_p_pos ~= conifers_c_con_sapling
|
or id ~= conifers_c_con_sapling
|
||||||
) then
|
) then
|
||||||
return false
|
return false
|
||||||
--else
|
--else
|
||||||
|
@ -436,11 +436,13 @@ function conifers:make_conifer(pos, conifer_type)
|
||||||
-- Let's check if we can grow a tree here.
|
-- Let's check if we can grow a tree here.
|
||||||
-- That means, we must have a column of "height" high which contains
|
-- That means, we must have a column of "height" high which contains
|
||||||
-- only air.
|
-- only air.
|
||||||
for j = 1, height - 1 do -- Start from 1 so we can grow a sapling.
|
local ti = vi + area.ystride -- Start from 1 so we can grow a sapling.
|
||||||
if nodes[area:index(pos.x, pos.y+j, pos.z)] ~= conifers_c_air then
|
for _ = 1, height - 1 do
|
||||||
|
if nodes[ti] ~= conifers_c_air then
|
||||||
-- Abort
|
-- Abort
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
ti = ti + area.ystride
|
||||||
end
|
end
|
||||||
|
|
||||||
local leaves_height = math.random(LEAVES_MINHEIGHT, LEAVES_MAXHEIGHT) -- Level from where the leaves grow.
|
local leaves_height = math.random(LEAVES_MINHEIGHT, LEAVES_MAXHEIGHT) -- Level from where the leaves grow.
|
||||||
|
@ -453,7 +455,7 @@ function conifers:make_conifer(pos, conifer_type)
|
||||||
for i = 0, height - 1 do
|
for i = 0, height - 1 do
|
||||||
current_block = {x=pos.x, y=pos.y+i, z=pos.z}
|
current_block = {x=pos.x, y=pos.y+i, z=pos.z}
|
||||||
-- Put a trunk block.
|
-- Put a trunk block.
|
||||||
nodes[area:index(pos.x, pos.y+i, pos.z)] = conifers_c_con_trunk
|
nodes[vi] = conifers_c_con_trunk
|
||||||
-- Put some leaves.
|
-- Put some leaves.
|
||||||
if i >= leaves_height then
|
if i >= leaves_height then
|
||||||
-- Put some leaves.
|
-- Put some leaves.
|
||||||
|
@ -480,6 +482,7 @@ function conifers:make_conifer(pos, conifer_type)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
vi = vi + area.ystride
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Put a top leaves block.
|
-- Put a top leaves block.
|
||||||
|
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
Loading…
Reference in New Issue