control behaviour type of an entity prototype

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
ichVII
Long Handed Inserter
Long Handed Inserter
Posts: 98
Joined: Mon Feb 27, 2017 10:16 pm
Contact:

control behaviour type of an entity prototype

Post by ichVII »

I would like to have something like LuaEntityProtoype.control_behaviour_type.

I assume that the control behaviour type does not depend on the specific entity, but only the entity prototype or even just the type of the entity prototype. But I belive there is no direct way to access it without placing an entity. (I may be wrong.)

Boodals
Fast Inserter
Fast Inserter
Posts: 129
Joined: Sun Feb 11, 2018 7:10 pm
Contact:

Re: control behaviour type of an entity prototype

Post by Boodals »

Most of the control behaviours are literally "XControlBehaviour" where X is the entity type. A hardcoded lookup table is probably enough, but I guess it would be nice to have that info available automatically so it stays up to date.

What it is you are doing where you need to know this?

ichVII
Long Handed Inserter
Long Handed Inserter
Posts: 98
Joined: Mon Feb 27, 2017 10:16 pm
Contact:

Re: control behaviour type of an entity prototype

Post by ichVII »

I am trying to change the mod conman. For a build-order it uses the create_entity command to place a ghost of the entity. This has the downside, that the created ghost does not try to merge with existing entities.

I intend to replace the create_entity command by set_blueprint_entities followed by build_blueprint. This has the desired merging behaviour. For the released version 0.17.2 of conman I made the change, but the newest GitHub version relies on first creating the ghost and then reading out its control behaviour type.

For many entities, the control behaviour type may agree with the entity type, but in particular the genericOnOff control behaviour type will probably be associated to many entity types.

justarandomgeek
Filter Inserter
Filter Inserter
Posts: 300
Joined: Fri Mar 18, 2016 4:34 pm
Contact:

Re: control behaviour type of an entity prototype

Post by justarandomgeek »

For one thing, you may want to use ConMan from github master, or wait another day or so for me to release that version, which handles all entities control behaviors correctly already. But also, what did you find not working, and why did you not report it on github, where i'll actually see it to fix it? The test suite is pretty complete...

Edit: also, the reason i create teh ghost first and then configure it is because not all the params that work for create_entity of a normal type will work for the ghost of that type. I forget specifically what doesn't, but you *have* to build the ghost first and then configure it for some of it anyway.

Edit2: and if you want to make blueprints with it, definitely wait a bit as it's getting new commands to edit blueprints. The build-ghost commands intentionally do not check for collisions, it's your job to manage that (and decon the previous building yourself). Changes to try to make the individual commands use blueprints will not be merged.

ichVII
Long Handed Inserter
Long Handed Inserter
Posts: 98
Joined: Mon Feb 27, 2017 10:16 pm
Contact:

Re: control behaviour type of an entity prototype

Post by ichVII »

In version 0.17.2, if you place an entity over an existing entity of the same name, it just places a ghost entity at that position and does not overwrite the existing entity. In particular, if the entity is a constant combinator, it creates a ghost of that entity instead of changing the signals provided by the constant combinator.

My modified version of the control file of 0.17.2 can be found at https://github.com/ichvii/factorio-conman

The core idea is replacing the call of create_entity by a call of set_blueprint_entities followed by deploying the blueprint. A few more steps make sure that the blueprint in the inventory is set to what it was before.

It sets the control_behaviour variables based on entproto.type and does not have an entity until every data is set.

The outcommented line 583 provided me with the necessary insights into get_blueprint_entities and set_blueprint_entities data.
Last edited by ichVII on Mon Nov 11, 2019 7:52 pm, edited 1 time in total.

justarandomgeek
Filter Inserter
Filter Inserter
Posts: 300
Joined: Fri Mar 18, 2016 4:34 pm
Contact:

Re: control behaviour type of an entity prototype

Post by justarandomgeek »

ichVII wrote:
Mon Nov 11, 2019 7:44 pm
In version 0.17.2, if you place an entity over an existing entity of the same name, it just places a ghost entity at that position and does not overwrite the existing entity.
Working as designed. Decon the original one first.
ichVII wrote:
Mon Nov 11, 2019 7:44 pm

Code: Select all

snip
This is my modified control of version 0.17.2. The core idea is replacing the call of create_entity by a call of set_blueprint_entities followed by deploying the blueprint. A few more steps make sure that the blueprint in the inventory is set to what it was before.
I'm not reviewing code on forums. Submit it as PR and i might, but it looks like it's already based on a version a few commits behind. If you use set_blueprint_entities for individual ghost commands i'll reject it.


Edit: You may also want to come visit discord and discuss this in a less painful platform. Forums suck.
Last edited by justarandomgeek on Mon Nov 11, 2019 7:56 pm, edited 1 time in total.

ichVII
Long Handed Inserter
Long Handed Inserter
Posts: 98
Joined: Mon Feb 27, 2017 10:16 pm
Contact:

Re: control behaviour type of an entity prototype

Post by ichVII »

I understand that that is how you want your mod to work. That is why i wasn't asking you to change your mod in the first place, but instead asking for help trying to make the adjustments I wanted for personal use.

Edit: I am trying to build a Microfactory of size 9x11 in seablock and anything, that can reduce the footprint of combinator logic, is really interesting to me.

Edit2: If your planned feature of adding an entity to a blueprint should rely on the same functions as the construction order, it would be in your interest to read the control behaviour type of an entity prototype, just like this topic initially suggested.

justarandomgeek
Filter Inserter
Filter Inserter
Posts: 300
Joined: Fri Mar 18, 2016 4:34 pm
Contact:

Re: control behaviour type of an entity prototype

Post by justarandomgeek »

ichVII wrote:
Mon Nov 11, 2019 7:55 pm
Edit2: If your planned feature of adding an entity to a blueprint should rely on the same functions as the construction order, it would be in your interest to read the control behaviour type of an entity prototype, just like this topic initially suggested.
I eventually arrived at this conclusion as well and went to add it myself and PR it, but astonishingly, the prototype C++ classes actually don't currently appear to know their own controlbehavior types! I'm now debating adding enough bits that they do know it, vs just building out the lookup table for entity prototype type to control behavior type in lua (which is probably less code, but slightly more tedious to keep up). I'm leaning towards just making the table.

Post Reply

Return to “Modding interface requests”