summaryrefslogtreecommitdiff
path: root/sealife.lua
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2016-01-21 14:59:28 +0000
committerTenPlus1 <kinsellaja@yahoo.com>2016-01-21 14:59:28 +0000
commit87031b60518731f62dbce0ffb1601b0c34d506c9 (patch)
tree707258c7ca090302fbbc7114966d551c849881da /sealife.lua
parentbd0fae584c0b0c3a04d41608acb4dfaf77554d91 (diff)
Optimize code, allfaces leaves by default, leaves walkable by default
Diffstat (limited to 'sealife.lua')
-rw-r--r--sealife.lua43
1 files changed, 28 insertions, 15 deletions
diff --git a/sealife.lua b/sealife.lua
index 41de5d0..6db5742 100644
--- a/sealife.lua
+++ b/sealife.lua
@@ -138,11 +138,11 @@ minetest.register_ore({
clust_scarcity = 10*10*10,
clust_num_ores = 24,
clust_size = 4,
- y_max = -14,
+ y_max = -12,
y_min = -100,
})
--- randomly generate coral or seaweed and have seaweed grow up to 10 high
+-- randomly generate coral or seaweed and have seaweed grow up to 14 high
minetest.register_abm({
nodenames = {"ethereal:sandy"},
neighbors = {"group:water"},
@@ -152,29 +152,42 @@ minetest.register_abm({
action = function(pos, node)
local sel = math.random(1, 5)
- if sel == 1
- or node.name == "ethereal:seaweed" then
+
+ pos.y = pos.y + 1
+
+ local nod = minetest.get_node(pos).name
+
+ if nod == "default:water_source"
+ and sel > 1 then
+
+ if minetest.get_node(pos).name == "default:water_source" then
+
+ minetest.swap_node(pos, {name = "ethereal:coral" .. sel})
+ end
+
+ return
+ end
+
+ if nod == "ethereal:seaweed"
+ or sel == 1 then
+
local height = 0
+ local high = 14
- while (minetest.get_node(pos).name == "ethereal:seaweed"
- or minetest.get_node(pos).name == "ethereal:sandy")
- and height < 14 do
+ while height < high
+ and minetest.get_node(pos).name == "ethereal:seaweed" do
height = height + 1
pos.y = pos.y + 1
end
- if height < 14
- and pos.y < 0
+ if pos.y < 1
+ and height < high
and minetest.get_node(pos).name == "default:water_source" then
- minetest.swap_node(pos, {name = "ethereal:seaweed"})
- end
- else
- pos.y = pos.y + 1
- if minetest.get_node(pos).name == "default:water_source" then
- minetest.swap_node(pos, {name = "ethereal:coral"..sel})
+ minetest.swap_node(pos, {name = "ethereal:seaweed"})
end
end
+
end,
})