local Bi_Industries = {} Bi_Industries.fertility = { -- out of 100, so 100 = always -- Vanilla ["grass-medium"] = 100, ["grass"] = 85, ["grass-dry"] = 75, ["dirt"] = 45, ["dirt-dark"] = 35, ["sand"] = 25, ["sand-dark"] = 15, ["red-desert"] = 10, ["red-desert-dark"] = 5, -- Alien biomes ["grass-red"] = 95, ["grass-orange"] = 95, ["grass-yellow"] = 95, ["grass-yellow-fade"] = 90, ["grass-purple-fade"] = 90, ["grass-purple"] = 95, ["dirt-red-dark"] = 45, ["dirt-brown-dark"] = 45, ["grass-blue-fade"] = 90, ["grass-blue"] = 95, ["dirt-red"] = 35, ["dirt-brown"] = 35, ["dirt-tan-dark"] = 45, ["dirt-dull-dark"] = 45, ["dirt-grey-dark"] = 45, ["dirt-tan"] = 25, ["dirt-dull"] = 25, ["dirt-grey"] = 25, ["sand-red-dark"] = 15, ["sand-orange-dark"] = 15, ["sand-gold-dark"] = 15, ["sand-dull-dark"] = 10, ["sand-grey-dark"] = 10, ["sand-red"] = 10, ["sand-orange"] = 10, ["sand-gold"] = 10, ["sand-dull"] = 7.5, ["sand-grey"] = 7.5, ["snow"] = 5, ["volcanic-cool"] = 5, } function Grow_tree(pos) local foundtree = false local surface = game.surfaces['nauvis'] local tree = surface.find_entity("seedling", pos) local currentTilename = surface.get_tile(pos.x, pos.y).name local fertility = 5 local growth_chance = math.random(100) -- Random value. Tree will grow if it's this value is smaller that the 'Fertility' value if tree then foundtree = true tree.destroy() --- Depending on Terain, choose tree type & Convert seedling into a tree if Bi_Industries.fertility[currentTilename] then fertility = Bi_Industries.fertility[currentTilename] end if currentTilename == "grass" then treetype = "tree-05" if growth_chance <= fertility and foundtree and surface.can_place_entity({ name=treetype, position=pos}) then surface.create_entity({ name=treetype, amount=1, position=pos}) end elseif currentTilename == "grass-medium" then treetype = "tree-04" if growth_chance <= fertility and foundtree and surface.can_place_entity({ name=treetype, position=pos}) then surface.create_entity({ name=treetype, amount=1, position=pos}) end elseif currentTilename == "grass-dry" then treetype = math.random(2) treetype = "tree-0".. treetype if growth_chance <= fertility and foundtree and surface.can_place_entity({ name=treetype, position=pos}) then surface.create_entity({ name=treetype, amount=1, position=pos}) end elseif currentTilename == "dirt" or currentTilename == "dirt-dark" then treetype = math.random(2) treetype = treetype + 5 treetype = "tree-0".. treetype if growth_chance <= fertility and foundtree and surface.can_place_entity({ name=treetype, position=pos}) then surface.create_entity({ name=treetype, amount=1, position=pos}) end elseif currentTilename == "red-desert" or currentTilename == "red-desert-dark" then treetype = math.random(2) treetype = treetype + 5 treetype = "tree-0".. treetype if growth_chance <= fertility and foundtree and surface.can_place_entity({ name=treetype, position=pos}) then surface.create_entity({ name=treetype, amount=1, position=pos}) end ---- Sand and Dark Sand & Any other Tile Type else treetype = math.random(3) if treetype == 1 then treetype = "tree-03" elseif treetype == 2 then treetype = "tree-08" else treetype = "tree-09" end if growth_chance <= fertility and foundtree and surface.can_place_entity({ name=treetype, position=pos}) then surface.create_entity({ name=treetype, amount=1, position=pos}) end end end end