I want to program the event on_forces_merged, but I don't know what happens with the entities in forces to be eliminated, are they destroyed? are they kept and the force is changed? or what happens?
I know it's a simple question, but I don't know of an event that merges forces for testing.
[Solved] What will happen to entities when merging two forces?
[Solved] What will happen to entities when merging two forces?
Last edited by yaim904 on Tue Jun 10, 2025 2:57 am, edited 1 time in total.
Solo entiendo español, pero si tu también lo entiendes, escríbeme


Everything i write in English is translated by Deepl.

Re: What will happen to entities when merging two forces?
All the entities in the "source" force should have their force changed to the "destination" force before the source force is deleted.
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
Re: What will happen to entities when merging two forces?
Thanks for the answer
I think the message got lost in translation.The entities will be destroyed?
I have to change the force on the entities?
Please be more detailed, I don't know much about the force.
Solo entiendo español, pero si tu también lo entiendes, escríbeme


Everything i write in English is translated by Deepl.

Re: What will happen to entities when merging two forces?
The force parameter of each entity is changed automatically by the game during the "game.merge_forces" function call. The entities continue to exist and the same LuaEntity references are still valid. You do not have to do anything, except any special logic that you need to run to make your mod work correctly when entities change what force they are in.
I used the word "should" because I once observed a weird case where entities were left with an invalid force parameter, but I couldn't replicate it.
I used the word "should" because I once observed a weird case where entities were left with an invalid force parameter, but I couldn't replicate it.
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
Re: What will happen to entities when merging two forces?
Now I understand, thanks for the clarification.
Out of curiosity, at what point do the forces combine? I can't imagine a scenario where two forces merge.Solo entiendo español, pero si tu también lo entiendes, escríbeme


Everything i write in English is translated by Deepl.

Re: [Solved] What will happen to entities when merging two forces?
1. It's impossible to delete forces. You can only merge them. You can choose to delete all the entities on the unwanted force before you merge them, or you can allow them to be reassigned.
2. Many mods make hidden forces to achieve certain things. The mod that lets you make overlapping independent roboport "channels" is one. The roboports for each channel are assigned a different force so the robots stay separated. When you remove a previously added robotport channel, it has to delete the hidden force by merging it with the player force.
2. Many mods make hidden forces to achieve certain things. The mod that lets you make overlapping independent roboport "channels" is one. The roboports for each channel are assigned a different force so the robots stay separated. When you remove a previously added robotport channel, it has to delete the hidden force by merging it with the player force.
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.