Pollution API events

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

avatarDr
Burner Inserter
Burner Inserter
Posts: 7
Joined: Wed Jul 06, 2016 1:53 pm
Contact:

Pollution API events

Post by avatarDr »

TL;DR
Factorio API is missing some pollution-related events which would better suit modders needs.
What ?
https://wiki.factorio.com/Pollution
Consider this topic tells us truth 'bout the mechanics, there are two events required:

on_pollution_spread - after (or before?) the pollution is recalculated.
LuaChunkIterator with all chunks modified (or all polluted?) would be enough for this event.

on_pollution_consumed - after pollution was consumed.
There it is required to somehow specify entities or types of consumers and the amount consumed. The best way to represent data here is an open question.

Optionally, there could be a sequence of on_pollution_consumed events, each for different consumer types (or even consumers) to clarify the order. I think it may depend on how it is calculated in game.
Why ?
There is a demand for more complex pollution-related mechanics already:
viewtopic.php?f=6&t=52012
Me personally only need second event as I'm intended to implement the idea above and make pollution evolution spawner-oriented:
viewtopic.php?f=25&t=52416
But if we're talking 'bout extending API, it would be easier to think it all through.
You can deal with it on your own or you can leave it to us...

P.s. What is "TL;DR" stands for?
Rseding91
Factorio Staff
Factorio Staff
Posts: 14845
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Pollution API events

Post by Rseding91 »

Such an event would be fired several thousand times per game tick which would have an unacceptable performance impact.
If you want to get ahold of me I'm almost always on Discord.
avatarDr
Burner Inserter
Burner Inserter
Posts: 7
Joined: Wed Jul 06, 2016 1:53 pm
Contact:

Re: Pollution API events

Post by avatarDr »

Rseding91 wrote:Such an event would be fired several thousand times per game tick which would have an unacceptable performance impact.
It does not need to be fired for each instance of consumption. It can be grouped by consumer type, or by chunk, or by smth else.
Entities can be lazily evaluated, I think I saw that you have such feature already.

> As soon as a chunk has reached 15.0 pollution it starts spreading in all four cardinal directions at a rate of 2% per game-second (60 ticks).
> Each spawner absorbs 20 + 0.01 * [chunks pollution] every game second (60 ticks)
Isn't it triggers only once per second? Or is it just simplification for neophytes while it is really applied every tick?
Rseding91
Factorio Staff
Factorio Staff
Posts: 14845
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Pollution API events

Post by Rseding91 »

avatarDr wrote:
Rseding91 wrote:Such an event would be fired several thousand times per game tick which would have an unacceptable performance impact.
It does not need to be fired for each instance of consumption. It can be grouped by consumer type, or by chunk, or by smth else.
Entities can be lazily evaluated, I think I saw that you have such feature already.

> As soon as a chunk has reached 15.0 pollution it starts spreading in all four cardinal directions at a rate of 2% per game-second (60 ticks).
> Each spawner absorbs 20 + 0.01 * [chunks pollution] every game second (60 ticks)
Isn't it triggers only once per second? Or is it just simplification for neophytes while it is really applied every tick?
Pollution is calculated each tick - you can watch it on the map as it works.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Ideas and Suggestions”