Page 1 of 1

Console command for trees

Posted: Sun May 16, 2021 6:16 am
by Ponade
Hello all,

does anyone have a console command for generating trees?

I tried this
/c local surface = game.player.surface; for y=0,40 do for x=0,24 do surface.create_entity({name="tree", amount=5000000, position={game.player.position.x+x, game.player.position.y+y}}) end end
But it isnt working with trees.

Thx for help

Re: Console command for trees

Posted: Sun May 16, 2021 6:32 am
by Silari
'tree' isn't an entity name, it's a type of entity. You'll need to choose a specific tree to make - 'tree-01' or such. The wiki lists all the vanilla tree names: https://wiki.factorio.com/Data.raw#tree

Re: Console command for trees

Posted: Sun May 16, 2021 6:35 am
by Ponade
Thank you,

it worked.

So is there a possibility to make a mixture of trees with one commend?

Re: Console command for trees

Posted: Sun May 16, 2021 9:43 pm
by Silari
Ponade wrote: Sun May 16, 2021 6:35 am Thank you,

it worked.

So is there a possibility to make a mixture of trees with one commend?
You'll have to fill out the array with the rest of the tree types yourself, but yes:

Code: Select all

/c local surface = game.player.surface; local trees = {"tree-01", "tree-02"}; for y=0,40 do for x=0,24 do surface.create_entity({name=trees[math.random(1,#trees)], amount=5000000, position={game.player.position.x+x, game.player.position.y+y}}) end end
That'll make a mix of tree-01 and tree-02. Just add the other tree types you want from the wiki link above and it'll randomly select one of the types in the array each time it adds a tree.

Re: Console command for trees

Posted: Mon May 17, 2021 8:10 am
by eradicator
What do you need this for?

Making a proper "natural" forest isn't that simple as tree types depend on biomes, and natural trees do not spawn on a perfect grid. If you don't mind a bit of manual work you could try /editor mode entity tab "Brush" or "Spray" - though that seems to only work one tree type at a time. Depending on use-case it might also be an option to generate a second surface and copy a game-generated natural forest from there (either via editor "clone" or script).