[Minor] Unexpected behaviour from fluid energy sources in inserters

This subforum contains all the issues which we already resolved.
User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2529
Joined: Fri Nov 06, 2015 7:41 pm

[Minor] Unexpected behaviour from fluid energy sources in inserters

Post by Deadlock989 »

This is not a big deal and might or might not have been fixed already: viewtopic.php?f=30&t=88263

I'm experimenting with machines that are directly powered by steam and mostly it's smooth sailing. You can get easy and expected results from the standard energy value of steam versus the specified energy_usage of the machine with definitions like this:

Code: Select all

energy_source = {
	type = "fluid",
	fluid_box = {
		filter = "steam",
		base_area = 1,
		base_level = -1,
		height = 2,
		production_type = "input-output",
		pipe_connections = {
			{ type="input-output", position = {2, 0} },
			{ type="input-output", position = {-2, 0} },
		},
		pipe_picture = blah,
		pipe_covers = blah,
	},
	maximum_temperature = 165
}
However inserters with a fluid energy source go completely bonkers when you use the same template. At a guess I'd say it's because you don't specify energy_usage for inserters - the energy value shown in-game is derived through some function of energy_per_rotation and energy_per_movement. What you get is madly fluctuating fluid consumption in the inserter, from zero to thousands of units/s back and forth - the inserter literally decides to randomly eat beyond 30 MW of steam power even though the in-game tooltip shows an average consumption of 35 kW.

You can work around it by specifying fluid_usage_per_tick manually, which gave me a bit of a headache and produces interesting numbers like 0.0186666666666667, but you can get sane behaviour that way.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3273
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [Minor] Unexpected behaviour from fluid energy sources in inserters

Post by boskid »

Hm... you are right.

When you specify a fluid energy source, it has to have fluid_usage_per_tick specified or scale_fluid_usage enabled. First one is to make sure fluid energy source consumes at most given volume of fluid in every tick the entity updates, while the scale_fluid_usage when enabled makes fluid energy source to dynamically scale the fluid usage based on the fluid fuel value (when burns fluid) or fluid heat capacity and temperature (when not burning fluid).

In case of crafting machines, when you skip both values (fluid_usage=0 and scale_fluid_usage=false), fluid_usage is updated based on the entity's energyUsage. For crafting machines energyUsage has a proper value so the fluid_usage is updated to non zero value, however in case of inserters, they do not have constant energy usage so they report energyUsage of 0. Because of this fluid_usage remains at 0. When it comes to fluid energy source update, fluid_usage is 0 meaning whole fluid box content can be consumed within a single tick (no upper limit) and because scale_fluid_usage is false, whole fluid box content is consumed immediately (max within limit).

It is quite easy to fix by providing max energy consumption as direct energy consumption so the fluid energy source properly computes the fluid_usage value, however that would mean the inserter will be consuming its max energy from fluid every tick when active, no scaling provided.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3273
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [Minor] Unexpected behaviour from fluid energy sources in inserters

Post by boskid »

Fixing it by providing max consumption as direct consumption would fix the issue but the LuaEntityPrototype::energy_usage would retun non-nil for inserters and that would be an issue. I fixed it for 1.1 in a different way: when deduced fluid_usage equals 0, scale_fluid_usage is forced to true.
Post Reply

Return to “Resolved Problems and Bugs”