forked from nalc/nalc_game
allow overriding papyrus and cactus grow functions
dont grow cactus on a lying one use minetest.get_node 2 times less do a bit what ShadowNinja wrote add comment return true if the plant is set
This commit is contained in:
parent
d0070f2b1a
commit
fe3c5a7090
|
@ -83,6 +83,7 @@ function default.node_sound_glass_defaults(table)
|
||||||
return table
|
return table
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Lavacooling
|
-- Lavacooling
|
||||||
--
|
--
|
||||||
|
@ -102,8 +103,8 @@ minetest.register_abm({
|
||||||
neighbors = {"group:water"},
|
neighbors = {"group:water"},
|
||||||
interval = 1,
|
interval = 1,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(...)
|
||||||
default.cool_lava_flowing(pos, node, active_object_count, active_object_count_wider)
|
default.cool_lava_flowing(...)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -112,37 +113,73 @@ minetest.register_abm({
|
||||||
neighbors = {"group:water"},
|
neighbors = {"group:water"},
|
||||||
interval = 1,
|
interval = 1,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(...)
|
||||||
default.cool_lava_source(pos, node, active_object_count, active_object_count_wider)
|
default.cool_lava_source(...)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Papyrus and cactus growing
|
-- Papyrus and cactus growing
|
||||||
--
|
--
|
||||||
|
|
||||||
|
function default.grow_cactus(pos, node)
|
||||||
|
if node.param2 ~= 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
pos.y = pos.y-1
|
||||||
|
if minetest.get_item_group(minetest.get_node(pos).name, "sand") == 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
pos.y = pos.y+1
|
||||||
|
local height = 0
|
||||||
|
while node.name == "default:cactus" and height < 4 and node.param2 == 0 do
|
||||||
|
height = height+1
|
||||||
|
pos.y = pos.y+1
|
||||||
|
node = minetest.get_node(pos)
|
||||||
|
end
|
||||||
|
if height == 4
|
||||||
|
or node.name ~= "air" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
minetest.set_node(pos, {name="default:cactus"})
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
function default.grow_papyrus(pos, node)
|
||||||
|
pos.y = pos.y-1
|
||||||
|
local name = minetest.get_node(pos).name
|
||||||
|
if name ~= "default:dirt_with_grass"
|
||||||
|
and name ~= "default:dirt" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if not minetest.find_node_near(pos, 3, {"group:water"}) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
pos.y = pos.y+1
|
||||||
|
local height = 0
|
||||||
|
while node.name == "default:papyrus" and height < 4 do
|
||||||
|
height = height+1
|
||||||
|
pos.y = pos.y+1
|
||||||
|
node = minetest.get_node(pos)
|
||||||
|
end
|
||||||
|
if height == 4
|
||||||
|
or node.name ~= "air" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
minetest.set_node(pos, {name="default:papyrus"})
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- wrapping the functions in abm action is necessary to make overriding them possible
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"default:cactus"},
|
nodenames = {"default:cactus"},
|
||||||
neighbors = {"group:sand"},
|
neighbors = {"group:sand"},
|
||||||
interval = 50,
|
interval = 50,
|
||||||
chance = 20,
|
chance = 20,
|
||||||
action = function(pos, node)
|
action = function(...)
|
||||||
pos.y = pos.y-1
|
default.grow_cactus(...)
|
||||||
local name = minetest.get_node(pos).name
|
|
||||||
if minetest.get_item_group(name, "sand") ~= 0 then
|
|
||||||
pos.y = pos.y+1
|
|
||||||
local height = 0
|
|
||||||
while minetest.get_node(pos).name == "default:cactus" and height < 4 do
|
|
||||||
height = height+1
|
|
||||||
pos.y = pos.y+1
|
|
||||||
end
|
end
|
||||||
if height < 4 then
|
|
||||||
if minetest.get_node(pos).name == "air" then
|
|
||||||
minetest.set_node(pos, {name="default:cactus"})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
|
@ -150,28 +187,12 @@ minetest.register_abm({
|
||||||
neighbors = {"default:dirt", "default:dirt_with_grass"},
|
neighbors = {"default:dirt", "default:dirt_with_grass"},
|
||||||
interval = 50,
|
interval = 50,
|
||||||
chance = 20,
|
chance = 20,
|
||||||
action = function(pos, node)
|
action = function(...)
|
||||||
pos.y = pos.y-1
|
default.grow_papyrus(...)
|
||||||
local name = minetest.get_node(pos).name
|
|
||||||
if name == "default:dirt" or name == "default:dirt_with_grass" then
|
|
||||||
if minetest.find_node_near(pos, 3, {"group:water"}) == nil then
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
pos.y = pos.y+1
|
|
||||||
local height = 0
|
|
||||||
while minetest.get_node(pos).name == "default:papyrus" and height < 4 do
|
|
||||||
height = height+1
|
|
||||||
pos.y = pos.y+1
|
|
||||||
end
|
|
||||||
if height < 4 then
|
|
||||||
if minetest.get_node(pos).name == "air" then
|
|
||||||
minetest.set_node(pos, {name="default:papyrus"})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- dig upwards
|
-- dig upwards
|
||||||
--
|
--
|
||||||
|
@ -185,6 +206,7 @@ function default.dig_up(pos, node, digger)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Leafdecay
|
-- Leafdecay
|
||||||
--
|
--
|
||||||
|
|
Loading…
Reference in New Issue
Block a user