Add data of mined items to data of tile_mined events

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
Pi-C
Smart Inserter
Smart Inserter
Posts: 1651
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Add data of mined items to data of tile_mined events

Post by Pi-C »

Currently, we get surface_index and a list of removed tiles from on_player_mined_tile and on_robot_mined_tile (plus player_index or the robot entity, respectively). But the tiles prototype may have the "minable" property, so mining a tile may return some other items. I can get minable.products from the tile prototypes, but it may have a probability, so I can't be sure I'll get the correct number of items the player has received. I'd like to have a new table "mined_items" added to the event that contains the names + exact numbers of items the player/robot got.

Use case: Bio Industries has "fertilizer" items that can be used to fertilize the ground. Actually, we use surface.set_tile to place a specific "fertile" tile on the spot where the fertilizer was used. However, it doesn't make sense that putting fertilizer on concrete would immediately change it to grass. So, if fertilizer is used on concrete or similar, I want to restore the original tile. However, I've already mined the tile (and got back the "concrete" item) when I used the fertilizer, and I want to remove the concrete from the player's inventory again (you're not supposed to convert fertilizer to concrete). This would be easy if I'd exactly know what items the player has received, and if the events "player mined a tile" and "player received items" were connected to each other.
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 interface requests”