Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Drones don't die after completing a task when logging into factorissimo-2-notnotmelon #7

Open
Eldrinn-Elantey opened this issue Jul 22, 2022 · 3 comments

Comments

@Eldrinn-Elantey
Copy link
Contributor

Eldrinn-Elantey commented Jul 22, 2022

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

@Aidiakapi
Copy link
Owner

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.

@notnotmelon
Copy link

Hello! I am the dev of the other mod. Let me know if theres any way I can help.

@Aidiakapi
Copy link
Owner

Aidiakapi commented Mar 7, 2023

Hey @notnotmelon!

There's essentially one of two things we'd have to make sure of:

  1. The robot entity's unit_number needs to remain unchanged, or
  2. Your mod needs to inform mine when a unit_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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants