blueprint scrip created entity

Place to get help with not working mods / modding interface.
Post Reply
CyberWizard2261
Inserter
Inserter
Posts: 23
Joined: Tue Jun 26, 2018 11:01 am
Contact:

blueprint scrip created entity

Post by CyberWizard2261 »

I'm creating a complex object with separate entities but the script created ones do not appear in blueprints and circuit cables disappear because of this can someone help me?

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5151
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: blueprint scrip created entity

Post by Klonan »

I would recommend using this event hook:
https://lua-api.factorio.com/latest/eve ... _blueprint

And then editing the blueprint to include the entities that the blueprint missed

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: blueprint scrip created entity

Post by eradicator »

@Klonan:

From personal experience:
  1. on_player_setup_blueprint doesn't tell you which entity has been blueprinted. Trying to guess from the bounding box sounds horribly hacky.
  2. If they're not in the blueprint there's probably no item that can place them. Is it save to add them anyway?
  3. Even if it is, adding hidden entities to blueprints means they show up in the components list and can be removed by the player. Thus it's not safe to rely on them.
It's really difficult to get this remotely usable without any mod support at all :|.

@OP:
If it's feasible for your mod, try making the entity that carries the wires the main object, and hide the others.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5151
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: blueprint scrip created entity

Post by Klonan »

eradicator wrote:@Klonan:

From personal experience:
  1. on_player_setup_blueprint doesn't tell you which entity has been blueprinted. Trying to guess from the bounding box sounds horribly hacky.
  2. If they're not in the blueprint there's probably no item that can place them. Is it save to add them anyway?
  3. Even if it is, adding hidden entities to blueprints means they show up in the components list and can be removed by the player. Thus it's not safe to rely on them.
It's really difficult to get this remotely usable without any mod support at all :|.

@OP:
If it's feasible for your mod, try making the entity that carries the wires the main object, and hide the others.
You use the item in the cursor stack to get the blueprint entities,
For example I do a similar thing for belt buffer mod,
I turn the belt buffer into the belt buffer placeholder:

https://github.com/Klonan/belt_buffer/b ... l.lua#L267

CyberWizard2261
Inserter
Inserter
Posts: 23
Joined: Tue Jun 26, 2018 11:01 am
Contact:

Re: blueprint scrip created entity

Post by CyberWizard2261 »

eradicator wrote:@OP:
If it's feasible for your mod, try making the entity that carries the wires the main object, and hide the others.
I want to make separate input and output for my composite entity (like a decider combinator) and I also plan to use some invisible constant combinators to save blue printable setup information I tried to look into other mods with composite entities (LTN and AAI) but could not find what I'm doing wrong

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: blueprint scrip created entity

Post by eradicator »

Klonan wrote:I would recommend using this event hook:
https://lua-api.factorio.com/latest/eve ... _blueprint
And then editing the blueprint to include the entities that the blueprint missed
Klonan wrote:You use the item in the cursor stack to get the blueprint entities,
You misunderstand. get_blueprint_entities only gets a table of the blueprint, but there is no association between i.e. the entity with entity_number = 2, and the actual LuaEntity that it was created from. So for that approach to work all relevant entities need to already be part of the blueprint, or else the bp won't contain the connections in the first place. Maybe in your usecase it works because the connection is between main/hidden and always the same?
bp.jpg
bp.jpg (121.4 KiB) Viewed 2648 times
@OP
Doing combinator logic on the lua side is performance-suicide (not sure what you actually want to do).
For storing specific info the alert message of the programmable speaker is supposedly worth a shot.

CyberWizard2261
Inserter
Inserter
Posts: 23
Joined: Tue Jun 26, 2018 11:01 am
Contact:

Re: blueprint scrip created entity

Post by CyberWizard2261 »

ok, I guess I'll have to open my idea:

My plan is to make a combinator capable of replacing several vanilla combinators by making several invisible combinators connected at both ends to invisible poles,
it would not use Lua when running, only when you are editing the circuits the input and output poles should be blue printable but for some reason, they are not

When I try to make a vanilla pole in the code it's blue printable and there's no problem but my invisible ones are not



Code: Select all

	

	{
		type = "electric-pole",
		name = "CW-output-pole",
		max_health = 10000,
		maximum_wire_distance = 9,
		supply_area_distance = 2,
		flags = {"placeable-player", "player-creation", "placeable-off-grid",},
		
		order = "y",
		icon = "__CW-power-combinator__/graphics/blank.png",
		icon_size = 1,
		draw_copper_wires = false,
		
		collision_box = {{0,0},{0,0}},
		collision_mask = {"not-colliding-with-itself"},
		selection_box = {{0.3,-0.5},{0.9,0.5}},
		
		connection_points = {
			{
				shadow = {
					green = {0.7,0.2},
					red = {0.7,-0.4}
				},
				wire = {
					green = {0.7,0.2},
					red = {0.7,-0.4}
				}
			},
		},

		radius_visualisation_picture = {
			filename = "__CW-power-combinator__/graphics/blank.png",
			height = 1,
			priority = "low",
			width = 1
		},

		pictures = {
			filename = "__CW-power-combinator__/graphics/blank.png",
			direction_count = 1,
			priority = "low",
			width = 1,
			height = 1,
			frame_count = 1,
			shift = {0, 0},
		}
	},

	

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: blueprint scrip created entity

Post by eradicator »

Only placeable entities are blueprintable. For that you either need an item that has the entity as place_result, or the entity prototype needs to specify <placeable_by = { item="iron-plate", count = 1}> (not sure if placeable_by may be an empty table, or count = 0?).

Btw, you're not the first with that idea *cough*.

CyberWizard2261
Inserter
Inserter
Posts: 23
Joined: Tue Jun 26, 2018 11:01 am
Contact:

Re: blueprint scrip created entity

Post by CyberWizard2261 »

thanks for that! My error was in not creating items for my poles I wished I learned that before

Post Reply

Return to “Modding help”