blueprint scrip created entity
-
- Inserter
- Posts: 23
- Joined: Tue Jun 26, 2018 11:01 am
- Contact:
blueprint scrip created entity
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
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
https://lua-api.factorio.com/latest/eve ... _blueprint
And then editing the blueprint to include the entities that the blueprint missed
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: blueprint scrip created entity
@Klonan:
From personal experience:
@OP:
If it's feasible for your mod, try making the entity that carries the wires the main object, and hide the others.
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.
@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
You use the item in the cursor stack to get the blueprint entities,eradicator wrote:@Klonan:
From personal experience:It's really difficult to get this remotely usable without any mod support at all .
- 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.
@OP:
If it's feasible for your mod, try making the entity that carries the wires the main object, and hide the others.
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
-
- Inserter
- Posts: 23
- Joined: Tue Jun 26, 2018 11:01 am
- Contact:
Re: blueprint scrip created entity
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 wrongeradicator wrote:@OP:
If it's feasible for your mod, try making the entity that carries the wires the main object, and hide the others.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: blueprint scrip created entity
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
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? @OPKlonan wrote:You use the item in the cursor stack to get the blueprint entities,
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.
-
- Inserter
- Posts: 23
- Joined: Tue Jun 26, 2018 11:01 am
- Contact:
Re: blueprint scrip created entity
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
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},
}
},
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: blueprint scrip created entity
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*.
Btw, you're not the first with that idea *cough*.
-
- Inserter
- Posts: 23
- Joined: Tue Jun 26, 2018 11:01 am
- Contact:
Re: blueprint scrip created entity
thanks for that! My error was in not creating items for my poles I wished I learned that before