I've searched through the webs and was surprised by how little information there is about Factorio's LuaEvents. Yes, most of them are pretty obvious, like on_tick :Р But there is one specific event that I just can't get the grasp of. I'm talking about on_robot_mined.
So, what does the official lua-api/factorio have to say about it? It's called when a robot mines an entity, contains event.robot -> LuaEntity and event.item_stack -> LuaItemStack. While it is actually called when it should be, it returns something weird. This event.item_stack thing does not behave like LuaItemStack. It cannot be set, cannot be cleared e.c.t. In other words, it looks like it is read-only, and that is really weird.
OK, but why exactly do I need this stack? Why can't I just use event.robot.get_inventory(1)[1]? Well, because it doesn't bloody work. It seems that when on_robot_mined is happening, there is nothing in the inventory of a robot. So, problem is that I can't access this item (that represents an entity just mined) in any way.
Now, let me show you some tests:
test 1
test 2
As you can see, there is definitely something weird with all of this. And it stops me from doing my thing, which is to make a handler that replaces item X with Y, when it is mined by a bot. I hope you people can help me (and many others, who will one day search for the same question).