grow new seaweed using param2 values
This commit is contained in:
parent
4f1b8de039
commit
8aaba4ba7b
31
sealife.lua
31
sealife.lua
@ -346,28 +346,35 @@ if ethereal.sealife == 1 then
|
|||||||
|
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
|
|
||||||
local sel = math.random(6)
|
-- grow new seaweed using param2 values
|
||||||
local pos_up = {x = pos.x, y = pos.y + 1, z = pos.z}
|
|
||||||
local nod = minetest.get_node(pos_up).name
|
|
||||||
|
|
||||||
if node.name == "ethereal:seaweed_rooted" then
|
if node.name == "ethereal:seaweed_rooted" then
|
||||||
|
|
||||||
local height = 0
|
local p2 = node.param2 or 16
|
||||||
|
local height = math.max(1, math.floor(p2 / 16))
|
||||||
|
|
||||||
while height < 14
|
if height > 13 then
|
||||||
and minetest.get_node(pos_up).name == "default:water_source" do
|
return
|
||||||
height = height + 1
|
|
||||||
pos_up.y = pos_up.y + 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if height < 3 or height > 14 then
|
height = height + 1
|
||||||
|
|
||||||
|
local tpos = {x = pos.x, y = pos.y + height + 1, z = pos.z}
|
||||||
|
|
||||||
|
if minetest.get_node(tpos).name ~= "default:water_source" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.set_node(pos, {name = "ethereal:seaweed_rooted",
|
minetest.set_node(pos, {name = "ethereal:seaweed_rooted",
|
||||||
param2 = (height - 1) * 16})
|
param2 = (height * 16)})
|
||||||
|
|
||||||
elseif nod == "default:water_source" then
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local sel = math.random(6)
|
||||||
|
local pos_up = {x = pos.x, y = pos.y + 1, z = pos.z}
|
||||||
|
local nod = minetest.get_node(pos_up).name
|
||||||
|
|
||||||
|
if nod == "default:water_source" then
|
||||||
|
|
||||||
if sel == 1 then
|
if sel == 1 then
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user