Compare commits

...

5 Commits

Author SHA1 Message Date
OldCoder ae5b7f33e2 Rename directory named as a literal newline to "n" 2022-09-04 21:10:43 -07:00
HybridDog 399453c00f Update README 2020-01-12 11:11:03 +01:00
HybridDog 25522d8843 Update README 2020-01-12 11:09:47 +01:00
HybridDog 6cc546b218 🐈
M  init.lua
2016-09-22 15:53:15 +02:00
HybridDog e5a9b76e25 🐈
M  init.lua
2016-07-22 21:51:35 +02:00
6 changed files with 18 additions and 11 deletions

View File

@ -1,8 +1,9 @@
```
--------------------------------------------------------------------------------
--
-- CONIFERS MOD
-- 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.
-- There are two types of conifers: regular and narrow.
@ -10,7 +11,10 @@
-- 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:
— add a TODO list
* Move settings to settingtypes.txt

View File

@ -256,7 +256,7 @@ function conifers:is_node_in_cube(nodenames, pos, size)
for x = pos.x-size, pos.x+size do
for y = pos.y-hs, pos.y+hs 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
or n.name == "ignore"
or conifers:table_contains(nodenames, n.name) then
@ -419,12 +419,12 @@ function conifers:make_conifer(pos, conifer_type)
nodes = manip:get_data()
-- Check if we can gros a conifer at this place.
local p_pos = area:index(pos.x, pos.y, pos.z)
local d_p_pos = nodes[p_pos]
local vi = area:indexp(pos)
local id = nodes[vi]
if nodes[area:index(pos.x, pos.y-1, pos.z)] ~= conifers_c_dirt_with_grass
and (d_p_pos ~= conifers_c_air
or d_p_pos ~= conifers_c_con_sapling
if nodes[vi - area.ystride] ~= conifers_c_dirt_with_grass
and (id ~= conifers_c_air
or id ~= conifers_c_con_sapling
) then
return false
--else
@ -436,11 +436,13 @@ function conifers:make_conifer(pos, conifer_type)
-- Let's check if we can grow a tree here.
-- That means, we must have a column of "height" high which contains
-- only air.
for j = 1, height - 1 do -- Start from 1 so we can grow a sapling.
if nodes[area:index(pos.x, pos.y+j, pos.z)] ~= conifers_c_air then
local ti = vi + area.ystride -- Start from 1 so we can grow a sapling.
for _ = 1, height - 1 do
if nodes[ti] ~= conifers_c_air then
-- Abort
return false
end
ti = ti + area.ystride
end
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
current_block = {x=pos.x, y=pos.y+i, z=pos.z}
-- 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.
if i >= leaves_height then
-- Put some leaves.
@ -480,6 +482,7 @@ function conifers:make_conifer(pos, conifer_type)
end
end
end
vi = vi + area.ystride
end
-- Put a top leaves block.

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB