[0.12.10] Circuit network get_blueprint_entities and create_entity

Bugs that are actually features.
Post Reply
RepairMan
Burner Inserter
Burner Inserter
Posts: 19
Joined: Sat Oct 03, 2015 12:00 pm
Contact:

[0.12.10] Circuit network get_blueprint_entities and create_entity

Post by RepairMan »

Steps to reproduce:
1. Connect 2 constant combinators like in the image below
Image
2. Place a blueprint of them in the first slot of your quicker
3. Execute the follow code in the console. It's gonna place the entity of the blueprint using the create_entity methode

Code: Select all

/c local es = game.player.character.get_inventory(defines.inventory.player_quickbar)[1].get_blueprint_entities() for k,v in pairs (es) do local g={} for k,v in pairs(v) do g[k]=v end g.inner_name=v.name g.inner_name=v.name g.position.x=g.position.x+game.player.position.x g.position.y=g.position.y+game.player.position.y g.force=game.player.force game.surfaces.nauvis.create_entity(g) end


Expected results: The 2 constant combinators connected by a red wire shut be placed at the players position

Actual results: The 2 constant combinators get placed without red wire connecting them
TODO List:
1. Build a von Neumann Probe Factory
2. Build a AI wich controls the factory
3. Send it all into space and watch as planets get eaten by it
4. PROFIT

Zeblote
Filter Inserter
Filter Inserter
Posts: 973
Joined: Fri Oct 31, 2014 11:55 am
Contact:

Re: [0.12.10] Circuit network get_blueprint_entities and create_entity

Post by Zeblote »

It doesn't even make sense to connect them like this, does it?

RepairMan
Burner Inserter
Burner Inserter
Posts: 19
Joined: Sat Oct 03, 2015 12:00 pm
Contact:

Re: [0.12.10] Circuit network get_blueprint_entities and create_entity

Post by RepairMan »

Zeblote wrote:It doesn't even make sense to connect them like this, does it?
It's an example, if you want just connect a constant combinator and a lamp or something else, the result shall be the same.
Last edited by RepairMan on Sun Oct 04, 2015 4:21 pm, edited 1 time in total.
TODO List:
1. Build a von Neumann Probe Factory
2. Build a AI wich controls the factory
3. Send it all into space and watch as planets get eaten by it
4. PROFIT

gheift
Fast Inserter
Fast Inserter
Posts: 188
Joined: Tue Mar 03, 2015 9:20 pm
Contact:

Re: [0.12.10] Circuit network get_blueprint_entities and create_entity

Post by gheift »

In the blueprint the connections are stored with an index, which is unique inside this blueprint, but not in the game. You copy the properties of the placed entities with

Code: Select all

local g={} for k,v in pairs(v) do g[k]=v end
and places them one by one.

The connection of the entites are stored for example as follow:

Code: Select all

  [1] = { name = "constant-combinator", connection = { "red" = 2, "green" = 3 } },
  [2] = { name = "constant-combinator", connection = { "red" = 1 } },
  [3] = { name = "constant-combinator", connection = { "green" = 1 } },
(This is not the actual format, only to demonstarte…)

When the entity is createrd with

Code: Select all

game.surfaces.nauvis.create_entity(g)
then game does not know, what entity 1, 2 or 3 is. A workaround would be to process the blueprint by yourself and call

Code: Select all

connect_neighbour
appropriatly. A better solution would be an exposed api function like

Code: Select all

game.surface.nauvis.place_blueprint(…)
https://forums.factorio.com/wiki/inde ... _neighbour

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: [0.12.10] Circuit network get_blueprint_entities and create_entity

Post by Adil »

create_entity is a simple function for spawning arbitrary entity, it is not supposed to copy your blueprints.
You'd need to manually obtain from blueprint and handle the additional properties like connections and filters.
Also, if you're planning on using that as a normal method of building, don't forget to raise on_entity_build event for each entity created, otherwise more than a number of mods will break down.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

RepairMan
Burner Inserter
Burner Inserter
Posts: 19
Joined: Sat Oct 03, 2015 12:00 pm
Contact:

Re: [0.12.10] Circuit network get_blueprint_entities and create_entity

Post by RepairMan »

Sorry for the trouble,
@gheift Could you help me with that?
TODO List:
1. Build a von Neumann Probe Factory
2. Build a AI wich controls the factory
3. Send it all into space and watch as planets get eaten by it
4. PROFIT

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [0.12.10] Circuit network get_blueprint_entities and create_entity

Post by kovarex »

Well, this is definitely not a bug. Script interface to build blueprint at certain location would make sense though.

Post Reply

Return to “Not a bug”