Moved bamboo grow code to its own function, and made that function global so that it can be called outside of mcl_bamboo.
This commit is contained in:
parent
6f05992c8b
commit
76669e1f3c
|
@ -772,7 +772,7 @@ register_craftings()
|
|||
dofile(minetest.get_modpath(modname) .. "/bambootoo.lua")
|
||||
|
||||
local BAMBOO_SOIL_DIST = -16
|
||||
local BAM_MAX_HEIGHT_STCHK = 11
|
||||
local BAM_MAX_HEIGHT_STPCHK = 11
|
||||
local BAM_MAX_HEIGHT_TOP = 15
|
||||
|
||||
--ABMs
|
||||
|
@ -780,7 +780,10 @@ minetest.register_abm({
|
|||
nodenames = {bamboo},
|
||||
interval = 40,
|
||||
chance = 40,
|
||||
action = function(pos, _)
|
||||
action = mcl_bamboo.grow_bamboo(pos,_),
|
||||
})
|
||||
|
||||
function mcl_bamboo.grow_bamboo(pos, _, force)
|
||||
local soil_pos
|
||||
if minetest.get_node_light(pos) < 8 then
|
||||
return
|
||||
|
@ -793,7 +796,7 @@ minetest.register_abm({
|
|||
found_soil = true
|
||||
soil_pos = chk_pos
|
||||
break
|
||||
elseif name ~= "mcl_bamboo:bamboo" then
|
||||
elseif name ~= bamboo then
|
||||
break
|
||||
end
|
||||
end
|
||||
|
@ -804,10 +807,10 @@ minetest.register_abm({
|
|||
local npos = vector.offset(pos, 0, py, 0)
|
||||
local name = minetest.get_node(npos).name
|
||||
local dist = vector.distance(soil_pos, npos)
|
||||
if dist >= BAM_MAX_HEIGHT_STCHK then
|
||||
if dist >= BAM_MAX_HEIGHT_STPCHK then
|
||||
-- stop growing check.
|
||||
if name == "air" then
|
||||
local height = math.random(BAM_MAX_HEIGHT_STCHK, BAM_MAX_HEIGHT_TOP)
|
||||
local height = math.random(BAM_MAX_HEIGHT_STPCHK, BAM_MAX_HEIGHT_TOP)
|
||||
if height == dist then
|
||||
minetest.set_node(npos, {name = "mcl_bamboo:bamboo_endcap"})
|
||||
end
|
||||
|
@ -815,14 +818,14 @@ minetest.register_abm({
|
|||
break
|
||||
end
|
||||
if name == "air" then
|
||||
minetest.set_node(npos, {name = "mcl_bamboo:bamboo"})
|
||||
minetest.set_node(npos, {name = bamboo})
|
||||
break
|
||||
elseif name ~= bamboo then
|
||||
break
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
-- Base Aliases.
|
||||
minetest.register_alias("bamboo_block", "mcl_bamboo:bamboo_block")
|
||||
|
|
Loading…
Reference in New Issue