Console command for trees

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
Ponade
Burner Inserter
Burner Inserter
Posts: 6
Joined: Fri May 07, 2021 8:01 am
Contact:

Console command for trees

Post 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

User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 489
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: Console command for trees

Post 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

Ponade
Burner Inserter
Burner Inserter
Posts: 6
Joined: Fri May 07, 2021 8:01 am
Contact:

Re: Console command for trees

Post by Ponade »

Thank you,

it worked.

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

User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 489
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: Console command for trees

Post 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.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Console command for trees

Post 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).
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Gameplay Help”