diff options
author | tenplus1 <kinsellaja@yahoo.com> | 2015-04-10 15:38:53 +0100 |
---|---|---|
committer | tenplus1 <kinsellaja@yahoo.com> | 2015-04-10 15:38:53 +0100 |
commit | 7d5b162ae9c7942bc21725bd310b46ebe8e4e4a2 (patch) | |
tree | 897e5de62611c8d8cea46219960744a7c0da7fb3 /sealife.lua | |
parent | efd4ab247c4fa11921bf0a65b61a432e674600e4 (diff) |
tidied & optimized code
Diffstat (limited to 'sealife.lua')
-rw-r--r-- | sealife.lua | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/sealife.lua b/sealife.lua index 2dafa25..4ac1389 100644 --- a/sealife.lua +++ b/sealife.lua @@ -120,7 +120,7 @@ minetest.register_ore({ height_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 10 high minetest.register_abm({ nodenames = {"ethereal:sandy"}, neighbors = {"group:water"}, @@ -130,31 +130,25 @@ minetest.register_abm({ action = function(pos, node) local sel = math.random(1,5) - if sel == 1 or minetest.get_node(pos).name == "ethereal:seaweed" then - + if sel == 1 or node.name == "ethereal:seaweed" then local height = 0 - while minetest.get_node(pos).name == "ethereal:seaweed" - or minetest.get_node(pos).name == "ethereal:sandy" + while (minetest.get_node(pos).name == "ethereal:seaweed" + or minetest.get_node(pos).name == "ethereal:sandy") and height < 14 do height = height + 1 pos.y = pos.y + 1 end - if height < 14 and pos.y < 0 then - if minetest.get_node(pos).name == "default:water_source" then - minetest.set_node(pos, {name="ethereal:seaweed"}) --- print ("GOING UP") - end + if height < 14 and pos.y < 0 + and minetest.get_node(pos).name == "default:water_source" then + minetest.set_node(pos, {name="ethereal:seaweed"}) end else - pos.y = pos.y + 1 - if minetest.get_node(pos).name == "default:water_source" then minetest.set_node(pos, {name="ethereal:coral"..sel}) --- print ("CORAL ", sel) end end |