Trigger on_force_created for default forces

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
PFQNiet
Filter Inserter
Filter Inserter
Posts: 289
Joined: Sat Sep 05, 2020 7:48 pm
Contact:

Trigger on_force_created for default forces

Post by PFQNiet »

Even though they are the default forces that always exist, I sort of imagined they'd be created at some point. However, on_force_created is not called for any of the player, enemy or neutral default forces.

My workaround:

Code: Select all

event_handler.add_lib{
  on_init = function()
    on_force_created{name=defines.events.on_force_created, tick=0, force=game.forces.player}
    on_force_created{name=defines.events.on_force_created, tick=0, force=game.forces.enemy}
    on_force_created{name=defines.events.on_force_created, tick=0, force=game.forces.neutral}
  end,
  events = {
    [defines.events.on_force_created] = on_force_created
  }
}
Seems hackish to me :D
curiosity
Filter Inserter
Filter Inserter
Posts: 471
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: Trigger on_force_created for default forces

Post by curiosity »

Your mod can always be added in the middle of a game, with who knows what forces already existing. Handling the default forces at the start of the game is indistinguishable from handling that.
PFQNiet
Filter Inserter
Filter Inserter
Posts: 289
Joined: Sat Sep 05, 2020 7:48 pm
Contact:

Re: Trigger on_force_created for default forces

Post by PFQNiet »

Ah that's a fair point. I hadn't considered that! Thanks for pointing it out.
Post Reply

Return to “Modding interface requests”