Emissions per tick in control.lua

Place to get help with not working mods / modding interface.
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

Emissions per tick in control.lua

Post by Dysoch »

Devs, got a question

Is it possible to add an event to control.lua that checks if there is an specific item in an entity and if so, it adds emissions per tick to that entity (thus creating pollution)

If this isnt possible, i would like the add it to modding interface request ;)
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6
n9103
Smart Inserter
Smart Inserter
Posts: 1067
Joined: Wed Feb 20, 2013 12:09 am
Contact:

Re: Emissions per tick in control.lua

Post by n9103 »

Dysoch wrote:Devs, got a question

Is it possible to add an event to control.lua that checks if there is an specific item in an entity and if so, it adds emissions per tick to that entity (thus creating pollution)

If this isnt possible, i would like the add it to modding interface request ;)
Possible hack-around would be to give the building a negative emissions per power, and just use productivity/speed modules to increase the effect.
Or, make a new module that only increases power use, but does it VERY well, but it's at the price point you're interested in using.
If you're interested in this being cheaper than regular module use, then a moderate multiplier and a moderate negative E/P will work.
If you're interested in it being higher priced, then a High multiplier and a very low negative E/P will do the trick.

(Disclaimer: it's been a few months since I messed with modding, not sure if anything's changed the way E/P works. Haven't noticed it in the dev logs I've read, but I've missed a few.)
Colonel Failure wrote:You can lose your Ecologist Badge quite quickly once you get to the point of just being able to murder them willy-nilly without a second care in the world.
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

Re: Emissions per tick in control.lua

Post by Dysoch »

n9103 wrote:
Dysoch wrote:Devs, got a question

Is it possible to add an event to control.lua that checks if there is an specific item in an entity and if so, it adds emissions per tick to that entity (thus creating pollution)

If this isnt possible, i would like the add it to modding interface request ;)
Possible hack-around would be to give the building a negative emissions per power, and just use productivity/speed modules to increase the effect.
Or, make a new module that only increases power use, but does it VERY well, but it's at the price point you're interested in using.
If you're interested in this being cheaper than regular module use, then a moderate multiplier and a moderate negative E/P will work.
If you're interested in it being higher priced, then a High multiplier and a very low negative E/P will do the trick.

(Disclaimer: it's been a few months since I messed with modding, not sure if anything's changed the way E/P works. Haven't noticed it in the dev logs I've read, but I've missed a few.)
First off all, negative emissions is cleaning pollution.

Second, i want it this way, so that 1 machine can both clean and create pollution (and other effects in the future).
To do that, i need to add it via an event, because otherwise it would cancel each other out.
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6
n9103
Smart Inserter
Smart Inserter
Posts: 1067
Joined: Wed Feb 20, 2013 12:09 am
Contact:

Re: Emissions per tick in control.lua

Post by n9103 »

Sorry, missed the adding part.
I don't know if it's possible, but can a power multiplier ever create energy? (even at very low initial energy use values?)
If so, then just take my idea and make both it and the reverse. The module in the machine would determine create or subtract.
Colonel Failure wrote:You can lose your Ecologist Badge quite quickly once you get to the point of just being able to murder them willy-nilly without a second care in the world.
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

Re: Emissions per tick in control.lua

Post by Dysoch »

n9103 wrote:Sorry, missed the adding part.
I don't know if it's possible, but can a power multiplier ever create energy? (even at very low initial energy use values?)
If so, then just take my idea and make both it and the reverse. The module in the machine would determine create or subtract.
Nono, the module is just a placeholder. The module does nothing. Its the event that does it. Power usage will be added in the data definitions. Just need something like this (this code is sloppy, and wont work)

Code: Select all

if iteminventory=(pollution-module) then
Entity.add "emission_per_tick= "100",
Thats all i want, not that the module does something.
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6
n9103
Smart Inserter
Smart Inserter
Posts: 1067
Joined: Wed Feb 20, 2013 12:09 am
Contact:

Re: Emissions per tick in control.lua

Post by n9103 »

I understood that part, but was trying to give you a work around until/unless it became possible.
Colonel Failure wrote:You can lose your Ecologist Badge quite quickly once you get to the point of just being able to murder them willy-nilly without a second care in the world.
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

Re: Emissions per tick in control.lua

Post by Dysoch »

n9103 wrote:I understood that part, but was trying to give you a work around until/unless it became possible.
Already have a workaround. I added 2 entities, 1 with positive and 1 with negative emissions.
But its crude, and i am hoping for this interface.
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6
slpwnd
Factorio Staff
Factorio Staff
Posts: 1835
Joined: Sun Feb 03, 2013 2:51 pm
Contact:

Re: Emissions per tick in control.lua

Post by slpwnd »

This is tricky, because the emissions_per_tick is a property of the prototype not the entity. What that means is that this is shared by all the entities defined by that prototype. Even if it would be possible to change that value from the script (which is not now, but most probably will be in the future) it wouldn't help, because it would affect all the entities of that entity type.
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

Re: Emissions per tick in control.lua

Post by Dysoch »

slpwnd wrote:This is tricky, because the emissions_per_tick is a property of the prototype not the entity. What that means is that this is shared by all the entities defined by that prototype. Even if it would be possible to change that value from the script (which is not now, but most probably will be in the future) it wouldn't help, because it would affect all the entities of that entity type.
i see, but it would be awesome when we can also create custom entity types.
then it would solve everything.
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6
Post Reply

Return to “Modding help”