clone_entities
Posted: Tue Nov 13, 2018 11:42 pm
I want to clone a bunch of entities. They are typically grouped together, but not necessarily in an area that clone_area would work well on (as there may be many entities that I do not want to clone in the same area). The conditions on whether or not to clone a specific entity is complex, and so should be done on the lua side. I do not want to clone entities individually, as that would be many, many API calls, and I would have to make sure to clone entities in a specific order (which is already done in clone_area) (eg clone rails before cloning trains).
If an entity on a different surface is given, just treat it like it's on the same surface, it shouldn't matter. Or if that can't be done for whatever reason, just throw an error or don't clone it.
It should return an array of Entity with the same indexes as the array that was passed into the function, with nils (or maybe false so that the # operator works?) where entities could not be cloned.
on_entity_cloned should be raised for each entity that was cloned.
Additionally, parameters similar to find_entities_filtered could be added to find the entities/tiles, which would essentially combine surface.clone_multiple({ entities = surface.find_entities_filtered({ ... }), ... }) into a single API call. However the overhead of cloning a bunch of entities is going to far outweigh the additional API call so it really isn't necessary.
ps: thx 4 on_entity_cloned
Code: Select all
surface.clone_entities(
{
entities (array of Entity to clone)
destination_offset (Vector, how far to move the entities)
destination_surface (SurfaceSpecification, optional, defaults to the same surface)
})
It should return an array of Entity with the same indexes as the array that was passed into the function, with nils (or maybe false so that the # operator works?) where entities could not be cloned.
on_entity_cloned should be raised for each entity that was cloned.
Additionally, parameters similar to find_entities_filtered could be added to find the entities/tiles, which would essentially combine surface.clone_multiple({ entities = surface.find_entities_filtered({ ... }), ... }) into a single API call. However the overhead of cloning a bunch of entities is going to far outweigh the additional API call so it really isn't necessary.
ps: thx 4 on_entity_cloned