mirror of
https://github.com/mt-mods/plantlife_modpack.git
synced 2024-11-12 13:20:39 +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
|
||||
|
||||
if run_tests then
|
||||
|
||||
-- Check node names
|
||||
if abstract_ferns.config.enable_horsetails then
|
||||
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_03"] ~= nil)
|
||||
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
|
||||
|
||||
-----------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -17,41 +17,28 @@ abstract_ferns.grow_tree_fern = function(pos)
|
|||
and minetest.get_node(pos_01).name ~= "default:junglegrass" then
|
||||
return
|
||||
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)]
|
||||
|
||||
if minetest.get_node(pos_02).name ~= "air" or size == 1 then -- TODO: Is ~= "air" intended behaviour?
|
||||
minetest.set_node(pos_01, {name="ferns:tree_fern_leaves"})
|
||||
elseif minetest.get_node(pos_03).name ~= "air" or size == 2 then
|
||||
minetest.set_node(pos_01, {name="ferns:fern_trunk"})
|
||||
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})
|
||||
local i = 1
|
||||
while (i < size-1) do
|
||||
if minetest.get_node({x = pos.x, y = pos.y + i + 1, z = pos.z}).name ~= "air" then
|
||||
break
|
||||
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
|
||||
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- TREE FERN LEAVES
|
||||
-----------------------------------------------------------------------------------------------
|
||||
|
||||
-- TODO: Both of these nodes look the same?
|
||||
|
||||
minetest.register_node("ferns:tree_fern_leaves", {
|
||||
description = "Tree Fern Crown (Dicksonia)",
|
||||
drawtype = "plantlike",
|
||||
|
|
Loading…
Reference in New Issue
Block a user