LuaSurface.pollute(...) without influence on evolution

NewTech
Burner Inserter
Burner Inserter
Posts: 11
Joined: Sat Jul 27, 2019 10:17 pm
Contact:

LuaSurface.pollute(...) without influence on evolution

Post by NewTech »

[Used google translate]

The LuaSurface.pollute(...) method has an implicit additional effect: it increases the value of the evolution factor when the parameter is positive.

Can I ask to add an analog of this method to the API, for example, called "set_pollute( MapPosition, double )" which will set the specified "double" value in the specified chunk (not add, but set) and without affecting the evolution factor.

At a minimum, this should be a lighter function than its current version and which will be suitable for mass use with manual (LUA) pollution control on the map.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15679
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LuaSurface.pollute(...) without influence on evolution

Post by Rseding91 »

That seems fine, however it’s not going to meaningful impact performance to do or not change the evolution factor.
If you want to get ahold of me I'm almost always on Discord.
NewTech
Burner Inserter
Burner Inserter
Posts: 11
Joined: Sat Jul 27, 2019 10:17 pm
Contact:

Re: LuaSurface.pollute(...) without influence on evolution

Post by NewTech »

Rseding91 wrote: Thu Apr 24, 2025 11:13 pm That seems fine, however it’s not going to meaningful impact performance to do or not change the evolution factor.
[Used google translate]
It may not have a significant effect on performance in the method itself, but when the very fact of the presence of this effect is undesirable, the load on performance can be felt more when it is necessary to build additional logic code to compensate for this effect.

Instead of being able to write like this:

Code: Select all

for ... in pairs( list_chunks ) do
	local pol_count = surface.get_pollution( pos_A )
	surface.set_pollute( pos_A , 0 )
	surface.set_pollute( pos_B , pol_count )
end
You have to additionally add to such: CONDITIONS (Branches) (especially in cycles) / Counts / API: Request and change the evolution factor, etc.
Only to remove the secondary effect with the growth of evolution from the ".pollute()" method

And here it becomes clear that the direct + indirect performance costs (LUA additional logic and actions) are no longer as small as it may seem for such a simple function.

P.S. Especially when you need to work with all the chunks in the world
berggen
Inserter
Inserter
Posts: 22
Joined: Tue Sep 01, 2020 7:12 pm
Contact:

Re: LuaSurface.pollute(...) without influence on evolution

Post by berggen »

Not against your specific request, but I think you should be able to do this already, maybe to help unblock your project :)

Code: Select all

local evo = force.get_evolution_factor_by_pollution(surface)
for ... in pairs( list_chunks ) do
	local pol_count = surface.get_pollution( pos_A )
	surface.set_pollute( pos_A , 0 )
	surface.set_pollute( pos_B , pol_count )
end
force.set_evolution_factor_by_pollution(evo, surface)
NewTech
Burner Inserter
Burner Inserter
Posts: 11
Joined: Sat Jul 27, 2019 10:17 pm
Contact:

Re: LuaSurface.pollute(...) without influence on evolution

Post by NewTech »

berggen wrote: Thu May 01, 2025 4:32 pm Not against your specific request, but I think you should be able to do this already, maybe to help unblock your project :)

Code: Select all

local evo = force.get_evolution_factor_by_pollution(surface)
for ... in pairs( list_chunks ) do
	local pol_count = surface.get_pollution( pos_A )
	surface.set_pollute( pos_A , 0 )
	surface.set_pollute( pos_B , pol_count )
end
force.set_evolution_factor_by_pollution(evo, surface)
[Used google translate]
Unfortunately, I have to disappoint you, what you are proposing is just part of this problem.

You can't remember the current value and "sort of" return it back after the cycle, since the evolution value will increase post-factum after the script has run.
It turns out that you are trying to change the value that has not yet been changed due to your intervention.


I have already implemented a crutch solution to this problem here:
https://mods.factorio.com/mod/Pollution ... bbon-world

And its meaning was this: that at the end of the cycle it was necessary to sum up the value of the transferred pollution, and then, using a formula, calculate the value of evolution that would have preceded the current one if this value of the summed pollution had been added to it.

And this solution seems to work perfectly accurately.



So, returning to the topic of the function request, perhaps I was wrong in that I initially did not describe in detail what the essence of the problem was and the different aspects affected directly and indirectly.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3942
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: LuaSurface.pollute(...) without influence on evolution

Post by boskid »

Implemented for 2.0.48: Added LuaSurface::set_pollution.
Post Reply

Return to “Implemented mod requests”