Raise an event for expansion base built alert.

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
heyqule
Long Handed Inserter
Long Handed Inserter
Posts: 88
Joined: Sun Mar 05, 2017 1:35 am
Contact:

Raise an event for expansion base built alert.

Post by heyqule »

Re: Expansion base built alert from https://factorio.com/blog/post/fff-445

it would be nice if expansion base built alert also raise an event.

My use case is that when this event triggers, unit control sends a group of army to kill them.

I could do it by tracking build groups position and on_sector_scanned. But the performance overheads made me don't want to do it, because majority of the scans are invalid. This becomes a lot worse when other mods speed up the radar scan speed.
danbopes
Fast Inserter
Fast Inserter
Posts: 122
Joined: Mon Feb 07, 2022 9:29 pm
Contact:

Re: Raise an event for expansion base built alert.

Post by danbopes »

There's an alert API. Why don't you just read the alerts?
heyqule
Long Handed Inserter
Long Handed Inserter
Posts: 88
Joined: Sun Mar 05, 2017 1:35 am
Contact:

Re: Raise an event for expansion base built alert.

Post by heyqule »

with luaplayer.get_alerts()? The mod needs check it every few seconds on all players for the alert that "a radar's 'far scan' might catch them at the right time if you're lucky".

Na. it's waste of compute cycles. Majority of the checks will be invalid.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 4812
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Raise an event for expansion base built alert.

Post by boskid »

This alert is tightly coupled to `on_biter_base_built` event as the alert is added by the build base behavior right before raising this event. Alerts are added to all forces that spawner's force is not friendly with (LuaForce::is_enemy) and target force having vision on the chunk (LuaForce::is_chunk_visible). I am not convinced about adding this event as it would be virtually a duplicate of `on_biter_base_built` with extra conditions added that are custom for your use case.
heyqule
Long Handed Inserter
Long Handed Inserter
Posts: 88
Joined: Sun Mar 05, 2017 1:35 am
Contact:

Re: Raise an event for expansion base built alert.

Post by heyqule »

Thanks boskid. That makes sense. At least this one checks only when they build. The other solutions need to run constantly.
Post Reply

Return to “Modding interface requests”