Change solar panel efficiency through modding API

Place to get help with not working mods / modding interface.
Post Reply
Xalos
Burner Inserter
Burner Inserter
Posts: 10
Joined: Wed Mar 08, 2017 6:03 am
Contact:

Change solar panel efficiency through modding API

Post 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?

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2904
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Change solar panel efficiency through modding API

Post by darkfrei »

You must add new prototype entities and replace all old withe new. I don't know why, something with optimization.
Last edited by darkfrei on Thu May 18, 2017 10:06 pm, edited 1 time in total.

Xalos
Burner Inserter
Burner Inserter
Posts: 10
Joined: Wed Mar 08, 2017 6:03 am
Contact:

Re: Change solar panel efficiency through modding API

Post 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.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3706
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Change solar panel efficiency through modding API

Post 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.

Xalos
Burner Inserter
Burner Inserter
Posts: 10
Joined: Wed Mar 08, 2017 6:03 am
Contact:

Re: Change solar panel efficiency through modding API

Post by Xalos »

So there's no way to change the efficiency linearly according to the current pollution? Darn. :D

Post Reply

Return to “Modding help”