LuaEntity.remove_control_behaviour

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
User avatar
protocol_1903
Filter Inserter
Filter Inserter
Posts: 420
Joined: Fri Sep 09, 2022 4:33 pm
Contact:

LuaEntity.remove_control_behaviour

Post by protocol_1903 »

A way to remove the control behavior of entities
Py and PyBlock developer, wielder of LUA in arbitrary ways. I make mods. Check them out, maybe.
https://mods.factorio.com/user/protocol_1903
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 4347
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: LuaEntity.remove_control_behaviour

Post by boskid »

I would prefer to not have this because it would have huge sideeffects: removing all circuit wires (if there are any), clearing all settings to defaults and in some cases it may even remove items (assembler's dump inventory is part of assembler behavior). That being said, there are at least 2 cases when behavior is removed right now: 1/ when removing last gate next to a wall, behavior on a wall is deleted, and 2/ when copying settings from other entity of the same type when source has no behavior and target has no wires; so if it was decided to be added regardless of sideeffects, it is doable.
User avatar
protocol_1903
Filter Inserter
Filter Inserter
Posts: 420
Joined: Fri Sep 09, 2022 4:33 pm
Contact:

Re: LuaEntity.remove_control_behaviour

Post by protocol_1903 »

Yes, i believe it should be reasonable as long as those side effects mentioned are documented. They also wouldn't be particularly difficult to work around.
Py and PyBlock developer, wielder of LUA in arbitrary ways. I make mods. Check them out, maybe.
https://mods.factorio.com/user/protocol_1903
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 4347
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: LuaEntity.remove_control_behaviour

Post by boskid »

I am curious, why exactly do you need to remove a control behavior? There should be no reason to create a control behavior in the first place if you are not trying to add a wire or to set a setting. There is a significant difference between "get_control_behavior" and "get_or_create_control_behavior" and they should not be mixed up.
User avatar
protocol_1903
Filter Inserter
Filter Inserter
Posts: 420
Joined: Fri Sep 09, 2022 4:33 pm
Contact:

Re: LuaEntity.remove_control_behaviour

Post by protocol_1903 »

viewtopic.php?p=686155

The exact topic you were just on. For removing control behavior if it isn't used. But yes, I will be attempting to not create control behavior if required, just need to update the mod.

Explanation: I create control behavior on entities when they're connected to circuit wires (assuming other conditions exist) but in reality basically every entity that's connected to circuit wires will have it created. I reset the control behaviors back to default if they are disconnected, but the control behavior still exists and I'd rather not have to replace the entity every single time just to clear control behavior.
Py and PyBlock developer, wielder of LUA in arbitrary ways. I make mods. Check them out, maybe.
https://mods.factorio.com/user/protocol_1903
Post Reply

Return to “Modding interface requests”