Created
March 28, 2022 02:07
-
-
Save corarona/b8596180276c1360b72c263034ce72e4 to your computer and use it in GitHub Desktop.
infinitrees
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local adjacents = { | |
{ x =-1, y = 0, z = 0 }, | |
{ x = 1, y = 0, z = 0 }, | |
{ x = 0, y = 0, z =-1 }, | |
{ x = 0, y = 0, z = 1 }, | |
} | |
local infinitree_node="mcl_core:acaciatree" | |
local leaves_node="mcl_core:acacialeaves" | |
minetest.register_abm({ | |
label = "infinitrees", | |
nodenames ={infinitree_node}, | |
interval = 1, | |
chance = 1, | |
catch_up = true, | |
action = function(pos) | |
local above=vector.add(pos,vector.new(0,1,0)) | |
local above_node=minetest.get_node(above) | |
if above_node.name ~= "air" and above_node.name ~= leaves_node then return end | |
local node=minetest.get_node(pos) | |
local op2=node.param2 | |
if math.random(10) == 1 then | |
if op2 > 10 then | |
minetest.set_node(above,{name=infinitree_node}) | |
else | |
minetest.set_node(vector.add(pos,adjacents[math.random(#adjacents)]),{name=infinitree_node,param2=op2+1}) | |
end | |
elseif op2 == 0 then | |
minetest.set_node(above,{name=infinitree_node}) | |
end | |
if math.random(4) > 1 then | |
for k,v in pairs(adjacents) do | |
local l=minetest.get_node(vector.add(pos,v)) | |
if l.name == "air" then | |
minetest.set_node(above,{name=leaves_node}) | |
end | |
end | |
end | |
end | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment