How to detect, if entity is active?

Place to get help with not working mods / modding interface.
Post Reply
KaraUL!
Inserter
Inserter
Posts: 23
Joined: Sat Mar 21, 2015 7:59 pm
Contact:

How to detect, if entity is active?

Post by KaraUL! »

Hi all. i have some problem. I have any entity of "assembling-machine" type - chemical-plant e.g. I need to do some actions runtime (in control.lua), ONLY when my chemical plant is producing its recipe. I tried options

Code: Select all

entity.active
(it shows "true" both when plant is working or staying idle)
and

Code: Select all

entity.energy
(the same amount, it changes only when entity connects\disconnects electric net. i hoped entity.energy depends on current energy usage)

Yea, i know we can get access to input/output inventory of assembling machine, and every game tick check if result item has been produced. But i dont think its a good idea cause of high frequency checks. Also player can almost immediately take "result item" from output inventory using inserters, so this check will not be valid. I hope you have any ideas?solutions, thanks.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13220
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: How to detect, if entity is active?

Post by Rseding91 »

Factorio 0.12 adds a method: entity.iscrafting() that will tell you what you're after.

In 0.11 there's currently no way to tell if a machine is crafting or smelting something.
If you want to get ahold of me I'm almost always on Discord.

KaraUL!
Inserter
Inserter
Posts: 23
Joined: Sat Mar 21, 2015 7:59 pm
Contact:

Re: How to detect, if entity is active?

Post by KaraUL! »

Rseding91 wrote:Factorio 0.12 adds a method: entity.iscrafting() that will tell you what you're after.

In 0.11 there's currently no way to tell if a machine is crafting or smelting something.

Thanks, i ll check

Post Reply

Return to “Modding help”