Mining drill real output slot
Mining drill real output slot
I'd like a way to access the item that the drill is holding to output to the ground, when there's already an item sitting on the ground blocking it.
Re: Mining drill real output slot
I still want this for Belt Overflow mod
Re: Mining drill real output slot
This suggestion, or something similar, would allow resolution of a years-old bug in Auto Deconstruct, so I didn't want to create a duplicate thread.
I am following up on a thread from 2018 viewtopic.php?f=7&t=63135 and report to the Auto Deconstruct mod author https://mods.factorio.com/mod/AutoDecon ... 000b9aa0ff. Since I have taken on maintenance of Auto Deconstruct, I would like to raise this issue again as was suggested in the 2018 thread.
The Problem
To summarize, the symptom is that the following events occur in order:
The Possible Hacks With Existing API
I have tried the following ways to determine if the miner holds an ore item internally:
The Request
Here are some possible mod interface changes that would fully resolve my issues:
I am following up on a thread from 2018 viewtopic.php?f=7&t=63135 and report to the Auto Deconstruct mod author https://mods.factorio.com/mod/AutoDecon ... 000b9aa0ff. Since I have taken on maintenance of Auto Deconstruct, I would like to raise this issue again as was suggested in the 2018 thread.
The Problem
To summarize, the symptom is that the following events occur in order:
- Mining drill performs a mining action, decrementing its last targeted resource entity and adding the ore item to a hidden internal inventory. (Note: when the mining drill drop target is blocked or full, sometimes decrementing the resource is delayed until space is available, but often it occurs immediately regardless of drop status.)
- Event on_resource_depleted fires for the resource entity, triggering the Auto Deconstruct code.
- Auto Deconstruct reads the type of the depleted resource, and marks the mining drill for deconstruction, which prevents it from dropping the ore item in the hidden internal inventory. At this time, entity.mining_progress and entity.bonus_mining_progress are small nonzero values indicating a progress of "1 tick" even though there is no resource to be mined.
- The depleted resource entity is destroyed automatically. entity.mining_target becomes invalid, and it is no longer possible to determine the type of resource that might be held in the mining drill's internal inventory.
- A player or robot mines the mining drill, and the ore item that was still inside the drill is lost.
- If instead of mining the marked drill, the player removes the deconstruction marker, the drill will output its final ore. It is this final ore that we are interested in preserving.
The Possible Hacks With Existing API
I have tried the following ways to determine if the miner holds an ore item internally:
- Check all the possible entity.get_inventory(x) values. This does not work because mining drills do not have official output inventories, as explained by Rseding in viewtopic.php?p=187063#p187063.
- Check entity.mining_state. This also does not work, because it is only valid for characters, not mining drills.
- Check entity.mining_progress and entity.bonus_mining_progress. These both give a small nonzero number (e.g. 0.0041667) when the last resource has been depleted, regardless of whether the last item has been dropped yet.
- Check entity.drop_target.can_insert({name="iron-ore"}). If the output is a chest, this will tell you if there would be space for the item to drop if you let the mining drill remain active for another tick. If the output is a belt or the ground, this always returns true, even if the belt is full and the mining drill status is "Waiting for space in destination".
- Check entity.mining_target. This is nil after the on_resource_depleted event concludes, even if the miner still holds an item in its internal inventory.
- Assume the mining drill always contains 1 ore item when on_resource_depleted is called, and spill it on the ground for a robot to pick up. This could produce either too many items (if for some reason it had already been dropped), or too few items (if a bonus item were produced in the same tick that the resource was depleted). This also means resources have to be retrieved from the logistic network instead of the intended belt.
- Wait a fixed number of ticks before marking the drill for deconstruction. This will still produce too few items if the drop target is full for a long time.
- Come up with code to watch the drop target belt / ground / whatever, and wait until they definitely have space for something, and time to drop it, before marking the drill for deconstruction. On crowded belts, this will increase overhead as drills are constantly polled until the rest of the patch dries up. This also somewhat defeats the purpose of the mod.
The Request
Here are some possible mod interface changes that would fully resolve my issues:
- Provide a LuaInventory or LuaItemStack handle for the item(s) that the drill removed from the resource entity but has not dropped yet.
- Provide a boolean flag or operating state code indicating whether the drill is waiting to drop any items.
- Change the mining behavior so that decrementing/depleting the resource entity is always delayed until the drill is able to drop the products of the last mining operation. (This could even be considered the root cause and an actual bug, given Rseding's assertion that drills do not have output inventories at all but the miner appears to hold an item for some time within itself.)
My mods: Multiple Unit Train Control, Smart Artillery Wagons
Maintainer of Vehicle Wagon 2, Cargo Ships, Honk
Maintainer of Vehicle Wagon 2, Cargo Ships, Honk
Re: Mining drill real output slot
I've fixed the drill so it won't delete the last item it is trying to output if mined before it happens (for the next release). Other changes can also be done but that is the root issue that I'm seeing.
If you want to get ahold of me I'm almost always on Discord.
Re: Mining drill real output slot
Thank you for the quick response! I will wait to see how it behaves with that fix in place.
My mods: Multiple Unit Train Control, Smart Artillery Wagons
Maintainer of Vehicle Wagon 2, Cargo Ships, Honk
Maintainer of Vehicle Wagon 2, Cargo Ships, Honk
Re: Mining drill real output slot
That might help with robot256' use case, but it doesn't address mine. I need to detect the ore so I can drop it on the ground when the output location is blocked.
Re: Mining drill real output slot
So is this why depleted mining drills are still holding ore in them? Maybe they shouldn't go forever silent before they empty?