Page 1 of 1

Change solar panel efficiency through modding API

Posted: Thu May 18, 2017 7:11 pm
by Xalos
I'm trying to change the efficiency of solar panels depending on the pollution in a tile at runtime from within a mod. However, I can't find any way to influence the efficiency of a solar panel. Is there a way to change the efficiency of an electric source at runtime rather than changing the prototype directly?

Re: Change solar panel efficiency through modding API

Posted: Thu May 18, 2017 7:20 pm
by darkfrei
You must add new prototype entities and replace all old withe new. I don't know why, something with optimization.

Re: Change solar panel efficiency through modding API

Posted: Thu May 18, 2017 7:36 pm
by Xalos
I can't seem to change the power output even for solar panels I'm creating through code.

Code: Select all

/c game.player.surface.create_entity({name='solar-panel',position=game.player.position,force=game.player.force,electric_output_flow_limit='10kW'})
I also tried power_production='10kW', but that didn't work either.

Re: Change solar panel efficiency through modding API

Posted: Fri May 19, 2017 1:19 am
by DaveMcW
Xalos wrote:at runtime
Impossible. You can only change efficiency in data.lua.

The best you can do at runtime is replace it with a different version that you defined in data.lua.

Re: Change solar panel efficiency through modding API

Posted: Fri May 19, 2017 2:01 am
by Xalos
So there's no way to change the efficiency linearly according to the current pollution? Darn. :D