generate resources on the map.

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
magals
Long Handed Inserter
Long Handed Inserter
Posts: 74
Joined: Fri Apr 08, 2016 7:30 pm
Contact:

generate resources on the map.

Post by magals »

Hi,
I play in the assembly of mods (PyAnodons, RSO) and when generating the map I turned off some resources (copper, iron, etc.), is it possible to generate them on the current map (more than one resource through the console), since the database is already very huge?
Serenity
Smart Inserter
Smart Inserter
Posts: 1017
Joined: Fri Apr 15, 2016 6:16 am
Contact:

Re: generate resources on the map.

Post by Serenity »

Changing resource generation only works on newly generated chunks
orzelek
Smart Inserter
Smart Inserter
Posts: 3924
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: generate resources on the map.

Post by orzelek »

Since you are using RSO you can regenerate whole map but you will need to edit map settings first to enable resources you disabled.

After you edit map settings you would need to call following commands:
/c remote.call("RSO", "regenConfig")
/c remote.call("RSO", "regenerate")

You can edit map gen settings using this API:
https://lua-api.factorio.com/latest/Lua ... n_settings
I think you need to read them as a table, modify and then assign whole table again.
JasonCurnow
Inserter
Inserter
Posts: 23
Joined: Wed Jan 03, 2018 4:44 am
Contact:

Re: generate resources on the map.

Post by JasonCurnow »

You can also generate resources from the console (hit ~ to bring it up). Be sure to consider that entering a console command like this will disable all achievements. Yeah, it's probably "cheating" but I use this for really big megabases where it's not practical to fetch ore from all the across the map each time.

An example console command is...

Code: Select all

/c local surface = game.player.surface; for y=0,40 do for x=0,24 do surface.create_entity({name="iron-ore", amount=5000000, position={game.player.position.x+x, game.player.position.y+y}}) end end 
This creates a patch of ore that is of X density (I used 5 million as a nice round number). It reads the coordinates (for y=0,40 do for x=0,24) and creates an ore chunk. In this case, it is going to create iron going 24 squares to the right and 40 squares down, so a total of 960 chunks. If you want to go up and left, you would put.. (for y=-40,0 do for x=-24,0)

You can generate iron-ore, copper-ore, uranium-ore or stone this way (among others). There are similar commands to add oil if you need it.

As a corollary, you can also delete resources the same way. The format is slightly different, but the idea is the same.

Code: Select all

/c for _, entity in ipairs(game.player.surface.find_entities_filtered{ area={{game.player.position.x, game.player.position.y}, {game.player.position.x+24, game.player.position.y+40}}, name="iron-ore"}) do entity.destroy() end 
This one goes right 24 spaces and down 40. If you want to adjust that up or down, change your X and Y numbers to be negative. (i.e. x-24 is left, y-24 is up)

You can destroy the same materials as you can create. As a bonus, you can also delete trees using the same kind of command, with a slightly different syntax, using a type instead of a name:

Code: Select all

/c for _, entity in ipairs(game.player.surface.find_entities_filtered{ area={{game.player.position.x, game.player.position.y}, {game.player.position.x+24, game.player.position.y+40}}, type="tree"}) do entity.destroy() end 
I haven't figured out a way to do this for rocks - If someone else knows the syntax, I'd like to know, as I spend a lot of time clearing them out.

It's very, very easy to mess this up - Be SURE to save your game before generating ore and reload it if things don't work as you expected them to.
Post Reply

Return to “Gameplay Help”