Page 1 of 1

How to detect, if entity is active?

Posted: Mon Apr 20, 2015 8:49 am
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.

Re: How to detect, if entity is active?

Posted: Tue Apr 21, 2015 4:32 pm
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.

Re: How to detect, if entity is active?

Posted: Wed Apr 29, 2015 7:51 am
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