robot256 / cargo_ships

factorio mod that adds cargo ships and other content to the game
5 stars 10 forks source link

Oil rig power improvements #8

Closed tburrows13 closed 1 year ago

tburrows13 commented 1 year ago

3 left the oil rig smoke offset because it is created by the power generator, which now spawns in a different place. This PR ensures that all rig power generators are teleported to the correct space and adjusts the smoke offset to compensate.

Secondly, there was a problem when modules were used to increase the power consumption of oil rigs too much, the power gen wouldn't keep up. Just increasing the power gen doesn't work because the smoke amount is proportional to the power usage, so it means that you don't get enough smoke. In this PR, I've relegated the power generator to primarily be for making smoke, and added a secondary-priority electric energy interface which can fill in as much power is needed.

Fully backwards compatible with old saves via a migration in on_configuration_changed.

robot256 commented 1 year ago

This is great. Definitely explains some of the smoke oddities. Is the migration needed to be in config changed? It looks like it might work in a Lua migration script, then it only has to run once.

The global.generators field is read but not written. Are you supposed to store the new or_power_electric somewhere as well?

tburrows13 commented 1 year ago

Is the migration needed to be in config changed? It looks like it might work in a Lua migration script, then it only has to run once.

Doesn't make any difference other than code cleanliness, but yes, probably could be its own lua migration.

Are you supposed to store the new or_power_electric somewhere as well?

No, global.or_generators is only used for periodically refuelling the generators with steam, but the electric power generators don't need refuelling, so they don't need adding here. Deletion when the oil rig is removed is done using find_entities_filtered.

robot256 commented 1 year ago

No, global.or_generators is only used for periodically refuelling the generators with steam, but the electric power generators don't need refuelling, so they don't need adding here.

So generators only make smoke when they consume steam? We can't make a gemerator that produces smoke without fuel?

tburrows13 commented 1 year ago

No, global.or_generators is only used for periodically refuelling the generators with steam, but the electric power generators don't need refuelling, so they don't need adding here.

So generators only make smoke when they consume steam? We can't make a gemerator that produces smoke without fuel?

Indeed. https://wiki.factorio.com/index.php?search=SmokeSource&title=Special%3ASearch&go=Go Only generators and burner/fluid energy sources can be smoke sources as far as I can see. Or independent projectiles or particle sources, but then the smoke amount wouldn't be correlated to the energy usage.

Entities like chemical plants have smoke, but that is just a hardcoded animation, which isn't affected by wind, and just plays slower when the machine is energy-starved (which doesn't look great).