on_preplayer_mined_item is not fired at right time.

Place to get help with not working mods / modding interface.
Post Reply
devilwarriors
Filter Inserter
Filter Inserter
Posts: 311
Joined: Sat Jan 09, 2016 1:11 am
Contact:

on_preplayer_mined_item is not fired at right time.

Post by devilwarriors »

Hi,

The api clearly say that on_preplayer_mined_item fire when the player start mining something
"Called when the player starts mining something"
http://lua-api.factorio.com/latest/even ... mined_item
Yet it actually fire on the same tick # as on_preplayer_mined_item, right before the entity is deleted.

so it's goes like this
- item start being mined
- mining progress bar reach 100%
- [...]
- tick begin
- [...]
- on_preplayer_mined_item is fired with the entity as a parameter
- entity is removed from the memory by the c++ logic.
- on_player_mined_item is fired with the result item_stack as a parameter
- [...]
- tick end
- [...]

Is this a bug or really a very niche case event with a wrong description? if it's not a bug can we get a proper event that fire when the player start mining something so we can do stuff like setting entity.minable to false and stop the mining. Or maybe remove the mining-tool from the tool_inventory. Something like that.

forum post where I'm describing what i'm trying to achieve -> viewtopic.php?f=25&t=31853

Thanks!
Last edited by devilwarriors on Tue Aug 30, 2016 2:35 am, edited 1 time in total.

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

Re: on_preplayer_mined_item is not fired at right time.

Post by Rseding91 »

The docs are just wrong.

As for your other comments: just set the entity to not minable to begin with if the player shouldn't be able to mine it.
If you want to get ahold of me I'm almost always on Discord.

devilwarriors
Filter Inserter
Filter Inserter
Posts: 311
Joined: Sat Jan 09, 2016 1:11 am
Contact:

Re: on_preplayer_mined_item is not fired at right time.

Post by devilwarriors »

Rseding91 wrote:The docs are just wrong.

As for your other comments: just set the entity to not minable to begin with if the player shouldn't be able to mine it.
But I wan't those entity to be mineable, just not by that particular mining-tool :(

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

Re: on_preplayer_mined_item is not fired at right time.

Post by Rseding91 »

devilwarriors wrote:
Rseding91 wrote:The docs are just wrong.

As for your other comments: just set the entity to not minable to begin with if the player shouldn't be able to mine it.
But I wan't those entity to be mineable, just not by that particular mining-tool :(
Then use the hardness property of entities and mining tools. You can set it up so a give entity isn't minable by a given tool but other tools can mine it.
If you want to get ahold of me I'm almost always on Discord.

devilwarriors
Filter Inserter
Filter Inserter
Posts: 311
Joined: Sat Jan 09, 2016 1:11 am
Contact:

Re: on_preplayer_mined_item is not fired at right time.

Post by devilwarriors »

oh nice, completely missed that, thanks!

devilwarriors
Filter Inserter
Filter Inserter
Posts: 311
Joined: Sat Jan 09, 2016 1:11 am
Contact:

Re: on_preplayer_mined_item is not fired at right time.

Post by devilwarriors »

so it's the damage that the mining-tool deal that decide what hardness it can mine?? how does the math work?

devilwarriors
Filter Inserter
Filter Inserter
Posts: 311
Joined: Sat Jan 09, 2016 1:11 am
Contact:

Re: on_preplayer_mined_item is not fired at right time.

Post by devilwarriors »

it's not the damage, and there really nothing else in the doc about hardness or how it work beside setting a ressources hardness.. so what am I looking for??

posila
Factorio Staff
Factorio Staff
Posts: 5202
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: on_preplayer_mined_item is not fired at right time.

Post by posila »

Fixed the documentation for 0.14.2.
Any entity can have "minable" property, which is table that can contain: mining_time, result/results, mining_particle, mining_trigger and hardness
Mining tool has property speed.
As I understand it, mining progress is multiplied by (speed - hardness), and if speed < hardness you won't be able to mine the entity.

Moved to Modding help.

devilwarriors
Filter Inserter
Filter Inserter
Posts: 311
Joined: Sat Jan 09, 2016 1:11 am
Contact:

Re: on_preplayer_mined_item is not fired at right time.

Post by devilwarriors »

posila wrote:Fixed the documentation for 0.14.2.
Any entity can have "minable" property, which is table that can contain: mining_time, result/results, mining_particle, mining_trigger and hardness
Mining tool has property speed.
As I understand it, mining progress is multiplied by (speed - hardness), and if speed < hardness you won't be able to mine the entity.

Moved to Modding help.
ah too bad that mean I can't use this for what I'm trying to achieve since what I want is a high speed mining tool that can only mine wood.

anyway, thx for updating the doc about this.

Post Reply

Return to “Modding help”