Page 1 of 1

LuaEntity.remove_control_behaviour

Posted: Thu Dec 11, 2025 11:17 pm
by protocol_1903
A way to remove the control behavior of entities

Re: LuaEntity.remove_control_behaviour

Posted: Thu Dec 11, 2025 11:32 pm
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.

Re: LuaEntity.remove_control_behaviour

Posted: Fri Dec 12, 2025 12:38 am
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.

Re: LuaEntity.remove_control_behaviour

Posted: Fri Dec 12, 2025 12:45 am
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.

Re: LuaEntity.remove_control_behaviour

Posted: Fri Dec 12, 2025 2:47 am
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.