Open Eldrinn-Elantey opened 2 years ago
Sorry for the late response, but this is probably because the robots themselves are "recreated" when they get teleported by the mod.
The way this mod works, is that essentially when a robot builds an entity, it's destroyed immediately, and when a robot destroys an entity, it's tracked, and destroyed once its inventory is empty (ie. it has dropped the items off at the player). If the original robot entity that picked something up, is recreated, the mod doesn't know that it should now destroy the next robot.
It'd probably be possible to fix it, with cooperation from the devs of the other mod, however, it's probably not really worth the time and effort, since the difference in gameplay is quite marginal.
Thanks for reporting it though.
Hello! I am the dev of the other mod. Let me know if theres any way I can help.
Hey @notnotmelon!
There's essentially one of two things we'd have to make sure of:
unit_number
needs to remain unchanged, orunit_number
changes.In essence, all robots that mine an item, are added to a "tracked" map, indexed by their unit_number
, once their inventory is emptied (by depositing them into the user's inventory), it'll be destroyed. See this code for details.
I'm not entirely sure what causes the unit_number
to change, since it doesn't seem like your mod is actively destroying and recreating the robots. That said, it's possible that it simply gets changed when it's teleported across surfaces.
In any case, if you're interesting in adding it, I can expose an API to try_untrack(unit_number) -> bool
and try_track(entity) -> bool
which you could call on a pre-teleported robot, and post-teleported robot.
This would look something like:
local was_tracked = early_construction.try_untrack(robot.unit_number)
robot.teleport(…)
if was_tracked then
early_construction.try_track(robot)
end
I haven't diagnosed in-depth, so please correct me if I misunderstood how your mod moves robots between surfaces, and if you want me to add such an API.
I play with your mod and with mods for factories from https://mods.factorio.com/mod/factorissimo-2-notnotmelon and I noticed that if you go into the factory when the drones return after dismantling, they are not destroyed but go into the inventory