Page 1 of 1

Allow access to built-in instant blueprint/deconstruction/upgrade logic outside of the editor

Posted: Wed Aug 21, 2019 4:54 pm
by raiguard
Hello. Some of the cheats in my Infinity Mode mod are instant blueprint/deconstruction/upgrade. I went and implemented these in LUA because vanilla's built-in logic is unavailable outside of the editor. However, my logic is simply too slow for me to be happy with it. I would like to request that the instant blueprint/deconstruction/upgrade logic in vanilla be made available to a player through script, probably by doing something like player.instant_blueprint == true.

I would also like to re-request that instant deconstruction in vanilla should raise events. The fact that it doesn't breaks many compound entities and there is absolutely no way to work around it.

Thanks!

Re: Allow access to built-in instant blueprint/deconstruction/upgrade logic outside of the editor

Posted: Wed Aug 21, 2019 6:32 pm
by Rseding91
The "editor" logic is just doing the same thing the Lua API does so there's nothing to expose there.

As for not raising events: that's by design and I have no plans on changing it. Any mods that use compound entities have to deal with that because it's just how it works in Factorio modding: you can never trust your entities to be valid unless you check .valid. Events are simply a nicer way to handle things but are not absolute.

Re: Allow access to built-in instant blueprint/deconstruction/upgrade logic outside of the editor

Posted: Wed Aug 21, 2019 6:46 pm
by DaveMcW
Events are the ONLY way to handle things.

If mods can't clean up dead entities after instant deconstuction in script_raise_destroy, they are forced to do it in on_tick.

Re: Allow access to built-in instant blueprint/deconstruction/upgrade logic outside of the editor

Posted: Wed Aug 21, 2019 9:12 pm
by raiguard
Yes, as DaveMCW said, the only other way is to check each one in on_tick, which is a completely unacceptable workaround. I guess it doesn't matter though, since I'll just have to keep using LUA anyway.

Thanks anyway.

Re: Allow access to built-in instant blueprint/deconstruction/upgrade logic outside of the editor

Posted: Wed Aug 21, 2019 10:02 pm
by Oktokolo
Rseding91 wrote:
Wed Aug 21, 2019 6:32 pm
As for not raising events: that's by design and I have no plans on changing it.
Is that because there then could be thousands of events raised in a single tick?
If yes, maybe having a special new event wich just signals, that mods should check for broken compounds wouldfix that. We would still have to check each of our compount entities by script. But we would at least know when to do it.

Re: Allow access to built-in instant blueprint/deconstruction/upgrade logic outside of the editor

Posted: Wed Aug 21, 2019 11:44 pm
by Rseding91
You seem to have missed my point: even if I added these events it doesn't cover 100% of the cases when an entity can be invalidated and a given mod gets no notification that it happens.

There will never be a 100% way to detect that some entity has been invalidated except to directly check ".valid" on it. That's a fact and if you want your mod to work correctly you have to account for it. If you don't care about that, you can just tell people that it doesn't work in all cases and they can decide if they want to use the mod or not.

Compound entities have been and most likely always will be a hack that doesn't work nicely in the game.

Re: Allow access to built-in instant blueprint/deconstruction/upgrade logic outside of the editor

Posted: Thu Aug 22, 2019 12:18 am
by DaveMcW
We don't want 100% coverage of invalid entities.

We want map editor instant deconstruction to work with mods. It is embarrassing for a modder to see their entity partially destroyed by the map editor. And if I was the author of the map editor, I would be embarrassed too.

Re: Allow access to built-in instant blueprint/deconstruction/upgrade logic outside of the editor

Posted: Thu Aug 22, 2019 1:21 am
by raiguard
I wouldn't have put it that way, but I essentially agree. I don't see any reason why instant deconstruction shouldn't raise events. Even if it's for performance reasons, I think the performance degredation would be a necessary cost to keep things consistent.

The main thing that baffles me is that instant blueprint raises events while instant deconstruction does not.