Cancel mining attempt per script

Place to get help with not working mods / modding interface.
Pi-C
Smart Inserter
Smart Inserter
Posts: 1759
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Cancel mining attempt per script

Post by Pi-C »

I want to use event scripts to prevent that certain entities can be mined, given certain conditions. (Yes, I know that "entity.minable = false" can be used -- but it's universal, not dependent on any conditions.)

We have
  • on_pre_player_mined_item (Called when the player finishes mining an entity, before the entity is removed from map.)
  • on_player_mined_entity (Called after the results of an entity being mined are collected just before the entity is destroyed. After this event any items in the buffer will be transferred into the player as if they came from mining the entity.)
and their equivalents for bots. But if these events are triggered, it is too late: the entity will be mined. I think it would be useful if the mining could be canceled in on_pre_X_mined_item, so subsequent events wouldn't be triggererd. Is there any way to accomplish that?
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Rseding91
Factorio Staff
Factorio Staff
Posts: 15967
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Cancel mining attempt per script

Post by Rseding91 »

Currently Factorio does not support even cancellation and I don't see that being supported any time in the future.
If you want to get ahold of me I'm almost always on Discord.
Pi-C
Smart Inserter
Smart Inserter
Posts: 1759
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Cancel mining attempt per script

Post by Pi-C »

Thanks for the answer! So I can stop wasting my time with trying to get it work. :-)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Post Reply

Return to “Modding help”