Page 1 of 1

Variable power usage

Posted: Wed May 20, 2015 3:09 pm
by wahming
Is there any way to change the amount of energy being used by a building?

Re: Variable power usage

Posted: Wed May 20, 2015 3:27 pm
by FishSandwich
entities.lua

Code: Select all

energy_usage = "150kW",
"for example".

Re: Variable power usage

Posted: Wed May 20, 2015 3:29 pm
by wahming
FishSandwich wrote:entities.lua

Code: Select all

energy_usage = "150kW",
"for example".
Oh sorry, I wasn't clear enough. Is there any way to change the energy usage dynamically, ingame?

Re: Variable power usage

Posted: Wed May 20, 2015 3:40 pm
by Incinirate
wahming wrote:
FishSandwich wrote:entities.lua

Code: Select all

energy_usage = "150kW",
"for example".
Oh sorry, I wasn't clear enough. Is there any way to change the energy usage dynamically, ingame?
Quoting from the wiki here, (https://forums.factorio.com/wiki/inde ... g_overview)

Changing existing definitions:

Code: Select all

data.raw.ammo["piercing-bullet-magazine"].magazine_size = 20
Or in your case, something like this?

Code: Select all

data.raw.assembling-machine["assembling-machine-2"].energy_usage = "300kW"

Re: Variable power usage

Posted: Wed May 20, 2015 3:47 pm
by wahming
Incinirate wrote: Quoting from the wiki here, (https://forums.factorio.com/wiki/inde ... g_overview)

Changing existing definitions:

Code: Select all

data.raw.ammo["piercing-bullet-magazine"].magazine_size = 20
Or in your case, something like this?

Code: Select all

data.raw.assembling-machine["assembling-machine-2"].energy_usage = "300kW"
I've never been able to get that piece of code to work in control.lua or the console. Somebody told me in another thread that it's only valid if processed at game startup. Please let me know if it works for you, and how.

Re: Variable power usage

Posted: Wed May 20, 2015 3:55 pm
by Incinirate
wahming wrote:
Incinirate wrote: Quoting from the wiki here, (https://forums.factorio.com/wiki/inde ... g_overview)

Changing existing definitions:

Code: Select all

data.raw.ammo["piercing-bullet-magazine"].magazine_size = 20
Or in your case, something like this?

Code: Select all

data.raw.assembling-machine["assembling-machine-2"].energy_usage = "300kW"
I've never been able to get that piece of code to work in control.lua or the console. Somebody told me in another thread that it's only valid if processed at game startup. Please let me know if it works for you, and how.
Yeah, I guess that makes sense since all the prototypes are loaded at game startup and all their properties are stored in a C construct. Hmm, it's so frustrating that we don't have any type of interface to work with the existing prototypes, I had this same problem attempting to change a recipe at runtime.

Re: Variable power usage

Posted: Sat May 30, 2015 1:02 am
by Wyrm
Did you remember to pass your energy consumption change function to an event handler? Just asking, because code that is to be run in mods are triggered during events.