Page 1 of 1
blueprint scrip created entity
Posted: Tue Jul 03, 2018 11:38 am
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?
Re: blueprint scrip created entity
Posted: Tue Jul 03, 2018 11:49 am
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
Re: blueprint scrip created entity
Posted: Tue Jul 03, 2018 12:03 pm
by eradicator
@Klonan:
From personal experience:
- on_player_setup_blueprint doesn't tell you which entity has been blueprinted. Trying to guess from the bounding box sounds horribly hacky.
- If they're not in the blueprint there's probably no item that can place them. Is it save to add them anyway?
- 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.
Re: blueprint scrip created entity
Posted: Tue Jul 03, 2018 12:24 pm
by Klonan
eradicator wrote:@Klonan:
From personal experience:
- on_player_setup_blueprint doesn't tell you which entity has been blueprinted. Trying to guess from the bounding box sounds horribly hacky.
- If they're not in the blueprint there's probably no item that can place them. Is it save to add them anyway?
- 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
Re: blueprint scrip created entity
Posted: Tue Jul 03, 2018 1:52 pm
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
Re: blueprint scrip created entity
Posted: Tue Jul 03, 2018 2:19 pm
by eradicator
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 (121.4 KiB) Viewed 3212 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.
Re: blueprint scrip created entity
Posted: Tue Jul 03, 2018 3:22 pm
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},
}
},
Re: blueprint scrip created entity
Posted: Tue Jul 03, 2018 5:15 pm
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*.
Re: blueprint scrip created entity
Posted: Tue Jul 03, 2018 7:04 pm
by CyberWizard2261
thanks for that! My error was in not creating items for my poles I wished I learned that before