mirror of
https://github.com/mt-mods/plantlife_modpack.git
synced 2024-12-26 02:20:20 +01:00
Re-wrote abstract_ferns.grow_tree_fern()
This commit is contained in:
parent
b815ffc578
commit
06c8d1c5ea
@ -36,6 +36,7 @@ dofile(minetest.get_modpath("ferns").."/crafting.lua")
|
|||||||
local run_tests = true -- set to false to skip
|
local run_tests = true -- set to false to skip
|
||||||
|
|
||||||
if run_tests then
|
if run_tests then
|
||||||
|
|
||||||
-- Check node names
|
-- Check node names
|
||||||
if abstract_ferns.config.enable_horsetails then
|
if abstract_ferns.config.enable_horsetails then
|
||||||
print("[Mod] " ..title.. " Checking horsetail item strings")
|
print("[Mod] " ..title.. " Checking horsetail item strings")
|
||||||
@ -50,6 +51,13 @@ if run_tests then
|
|||||||
assert(minetest.registered_items["ferns:fern_02"] ~= nil)
|
assert(minetest.registered_items["ferns:fern_02"] ~= nil)
|
||||||
assert(minetest.registered_items["ferns:fern_03"] ~= nil)
|
assert(minetest.registered_items["ferns:fern_03"] ~= nil)
|
||||||
end
|
end
|
||||||
|
if abstract_ferns.config.enable_treefern then
|
||||||
|
print("[Mod] ".. title .." Checking tree fern item strings")
|
||||||
|
assert(minetest.registered_items["ferns:tree_fern_leaves"] ~= nil)
|
||||||
|
assert(minetest.registered_items["ferns:tree_fern_leaves_02"] ~= nil)
|
||||||
|
assert(minetest.registered_items["ferns:fern_trunk"] ~= nil)
|
||||||
|
assert(minetest.registered_items["ferns:sapling_tree_fern"] ~= nil)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
|
@ -18,40 +18,27 @@ abstract_ferns.grow_tree_fern = function(pos)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local pos_02 = {x = pos.x, y = pos.y + 2, z = pos.z}
|
|
||||||
local pos_03 = {x = pos.x, y = pos.y + 3, z = pos.z}
|
|
||||||
local pos_04 = {x = pos.x, y = pos.y + 4, z = pos.z}
|
|
||||||
local pos_05 = {x = pos.x, y = pos.y + 5, z = pos.z}
|
|
||||||
|
|
||||||
local size = math.random(1, 5)
|
local size = math.random(1, 5)
|
||||||
local crown = ({ "ferns:tree_fern_leaves", "ferns:tree_fern_leaves_02" })[math.random(1, 2)]
|
local crown = ({ "ferns:tree_fern_leaves", "ferns:tree_fern_leaves_02" })[math.random(1, 2)]
|
||||||
|
|
||||||
if minetest.get_node(pos_02).name ~= "air" or size == 1 then -- TODO: Is ~= "air" intended behaviour?
|
local i = 1
|
||||||
minetest.set_node(pos_01, {name="ferns:tree_fern_leaves"})
|
while (i < size-1) do
|
||||||
elseif minetest.get_node(pos_03).name ~= "air" or size == 2 then
|
if minetest.get_node({x = pos.x, y = pos.y + i + 1, z = pos.z}).name ~= "air" then
|
||||||
minetest.set_node(pos_01, {name="ferns:fern_trunk"})
|
break
|
||||||
minetest.set_node(pos_02, {name=crown})
|
|
||||||
elseif minetest.get_node(pos_04).name ~= "air" or size == 3 then
|
|
||||||
minetest.set_node(pos_01, {name="ferns:fern_trunk"})
|
|
||||||
minetest.set_node(pos_02, {name="ferns:fern_trunk"})
|
|
||||||
minetest.set_node(pos_03, {name=crown})
|
|
||||||
elseif minetest.get_node(pos_05).name ~= "air" or size == 4 then
|
|
||||||
minetest.set_node(pos_01, {name="ferns:fern_trunk"})
|
|
||||||
minetest.set_node(pos_02, {name="ferns:fern_trunk"})
|
|
||||||
minetest.set_node(pos_03, {name="ferns:fern_trunk"})
|
|
||||||
minetest.set_node(pos_04, {name=crown})
|
|
||||||
elseif size == 5 then
|
|
||||||
minetest.set_node(pos_01, {name="ferns:fern_trunk"})
|
|
||||||
minetest.set_node(pos_02, {name="ferns:fern_trunk"})
|
|
||||||
minetest.set_node(pos_03, {name="ferns:fern_trunk"})
|
|
||||||
minetest.set_node(pos_04, {name="ferns:fern_trunk"})
|
|
||||||
minetest.set_node(pos_05, {name=crown})
|
|
||||||
end
|
end
|
||||||
|
minetest.set_node({x = pos.x, y = pos.y + i, z = pos.z}, { name = "ferns:fern_trunk" })
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.set_node({x = pos.x, y = pos.y + i, z = pos.z}, { name = crown })
|
||||||
end
|
end
|
||||||
|
|
||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
-- TREE FERN LEAVES
|
-- TREE FERN LEAVES
|
||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
-- TODO: Both of these nodes look the same?
|
||||||
|
|
||||||
minetest.register_node("ferns:tree_fern_leaves", {
|
minetest.register_node("ferns:tree_fern_leaves", {
|
||||||
description = "Tree Fern Crown (Dicksonia)",
|
description = "Tree Fern Crown (Dicksonia)",
|
||||||
drawtype = "plantlike",
|
drawtype = "plantlike",
|
||||||
|
Loading…
Reference in New Issue
Block a user