Objects created during "normal" command (ie commands.add_command, not /c) are not "owned" by that mod

This subforum contains all the issues which we already resolved.
User avatar
Reika
Filter Inserter
Filter Inserter
Posts: 587
Joined: Tue May 19, 2015 1:56 am
Contact:

Objects created during "normal" command (ie commands.add_command, not /c) are not "owned" by that mod

Post by Reika »

I noticed it with LuaRendering objects, but there are probably others. If you try and remove objects owned by a given mod, eg rendering.clear(modname), it will not remove ones added by commands that mod owns. It will remove ones spawned by the same code, but with the root caller being some event or something rather than running the command.

Rseding briefly commented on this on the discord:
Console commands run in the scenario lua context.
Why would they be associated with some other mod?
And while that makes sense for "loose" /c commands, it does not for ones added by - and therefore completely owned by - a mod.


This has a really nasty gotcha in it, too: It means that any command designed to "refresh" these objects will work perfectly...once. Upon which time it is never going to work again, as the new ones created are not owned by the mod. I nearly fell for that trap creating exactly that sort of command in my Bioluminescence mod.
Image
Rseding91
Factorio Staff
Factorio Staff
Posts: 16034
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Objects created during "normal" command (ie commands.add_command, not /c) are not "owned" by that mod

Post by Rseding91 »

Thanks for the report. I fixed this last night shortly after we talked about it in Discord.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Resolved Problems and Bugs”