Hi all,
I am a bit new with the Factorio API, but not new to programming/scripting.
I wish to create a base surface for a scenario, that when the win condition or lose condition is met, the "base" surface is copied to a new "playing" surface (aka, restart the game again without the need to restart the server and change the save file)
As I understand it, the only way I currently see to be able to do this is to generate a new surface using the same map settings as the base, and use baseSurface.find_entities(), loop through these and re-place them onto the newly created surface.
Is this the best way of doing this or does Factorio already have some built in functionality to copy and paste a whole surface to another?
What is the best way to copy and paste a surface?
Re: What is the best way to copy and paste a surface?
Would also need to consider any trees, biters, etc. that need to be removed from the freshly generated surface.
I don't think there is any way to straight copy, you either have find_entity + create_entity, or you can make a blueprint (either manually in advance, or create_blueprint) and place it (build_blueprint), but then you need to "revive" all the placed ghosts (on_entity_built or find_entity would work)
I don't think there is any way to straight copy, you either have find_entity + create_entity, or you can make a blueprint (either manually in advance, or create_blueprint) and place it (build_blueprint), but then you need to "revive" all the placed ghosts (on_entity_built or find_entity would work)
Re: What is the best way to copy and paste a surface?
Create a new surface on start, with specific MapGenSettings, especially the "seed" is important here. Move all the players to this surface on connect.
Then when you are done, create a new surface with these same settings, move all the players to it, and delete the original surface? Same MapGenSettings will provide the same map every time.
(You simply don't use the 'nauvis' surface, as you cannot delete that one)
Then when you are done, create a new surface with these same settings, move all the players to it, and delete the original surface? Same MapGenSettings will provide the same map every time.
(You simply don't use the 'nauvis' surface, as you cannot delete that one)
Re: What is the best way to copy and paste a surface?
Hi Daid,
While this will generate the same surface map layout, it will not copy entities that are created on the map
Let's say my map had a pre-built base in it, nothing fancy, just some turrets, walls and belts - i want these to be copied each time, my current idea of baseSurface.find_entities() is most likely the only method of achieving this.
While this will generate the same surface map layout, it will not copy entities that are created on the map
Let's say my map had a pre-built base in it, nothing fancy, just some turrets, walls and belts - i want these to be copied each time, my current idea of baseSurface.find_entities() is most likely the only method of achieving this.
Re: What is the best way to copy and paste a surface?
I just have to ask why? as in why copy the surface and everything on it if you are not changing anything?
Re: What is the best way to copy and paste a surface?
On init save all entities to table and read from it for items placing.
Re: What is the best way to copy and paste a surface?
I have this idea in my head to create a game mode that resets itself whenever it's won or failed, because of this i want the same starting area to be spawned from the "baseSurface" every time, including any entities that I place down in the map editor, such as drills, belts, power poles etc.Nexela wrote:I just have to ask why? as in why copy the surface and everything on it if you are not changing anything?
These entities can be moved, deleted or killed by either aliens or players during play, thus the base surface must be considered an immutable object
I will give this a go, thank you.darkfrei wrote:On init save all entities to table and read from it for items placing.