How to determine if machine is running?

Place to get help with not working mods / modding interface.
Rockstar04
Fast Inserter
Fast Inserter
Posts: 171
Joined: Sun Feb 17, 2013 4:31 pm
Contact:

How to determine if machine is running?

Post by Rockstar04 »

I am trying to make a mod that adds crude early tech speed modules that slowly do damage to the machines they are placed in. Ideally I would only like the machines to be damaged when they are running (miners mining, assembly machines assembling, etc). For assembly machines the is_crafting method is perfect, but I cant use it with mining drills.

How can I determine when a machine is actually working?

Thanks for the help everyone, this is the first time I've given LUA scripting a go, normally I just stick to making plain old new entities and item mods, so this is new for me.
Natha
Filter Inserter
Filter Inserter
Posts: 276
Joined: Sun Mar 15, 2015 1:48 pm
Contact:

Re: How to determine if machine is running?

Post by Natha »

For mining drills there is afaik no method.
Maybe the mining_state property?
Supercheese
Filter Inserter
Filter Inserter
Posts: 841
Joined: Mon Sep 14, 2015 7:40 am
Contact:

Re: How to determine if machine is running?

Post by Supercheese »

It would be resource-intensive, but you could check if the crafting_progress variable has changed lately, if so then crafting has clearly happened, if it hasn't changed at all, then no crafting has happened.
Natha
Filter Inserter
Filter Inserter
Posts: 276
Joined: Sun Mar 15, 2015 1:48 pm
Contact:

Re: How to determine if machine is running?

Post by Natha »

Supercheese wrote:It would be resource-intensive, but you could check if the crafting_progress variable has changed lately, if so then crafting has clearly happened, if it hasn't changed at all, then no crafting has happened.
That also doesnt work for mining drills.
Rockstar04
Fast Inserter
Fast Inserter
Posts: 171
Joined: Sun Feb 17, 2013 4:31 pm
Contact:

Re: How to determine if machine is running?

Post by Rockstar04 »

Alright, this at least makes me feel better that I didn't miss something simple.

Thanks for the suggestions
Supercheese
Filter Inserter
Filter Inserter
Posts: 841
Joined: Mon Sep 14, 2015 7:40 am
Contact:

Re: How to determine if machine is running?

Post by Supercheese »

Natha wrote:
Supercheese wrote:It would be resource-intensive, but you could check if the crafting_progress variable has changed lately, if so then crafting has clearly happened, if it hasn't changed at all, then no crafting has happened.
That also doesnt work for mining drills.
Wellp, there goes that idea.
Post Reply

Return to “Modding help”