Edit blueprint in a mod
Edit blueprint in a mod
Hi
Is that possible to edit a blueprint in a mod (add, delete, modify or replace elements etc.)? If yes, how?
Thanks
Niko
Is that possible to edit a blueprint in a mod (add, delete, modify or replace elements etc.)? If yes, how?
Thanks
Niko
Re: Edit blueprint in a mod
Short answere: yes.
There are events for when a blueprint is created where you can modify things before they are encoded as a blueprint. Just search the list of events in the API for blueprint.
There are also mods that modify a blueprint later. No idea how but you can look there for how to do it. For example https://mods.factorio.com/mod/LandfillEverything
There are events for when a blueprint is created where you can modify things before they are encoded as a blueprint. Just search the list of events in the API for blueprint.
There are also mods that modify a blueprint later. No idea how but you can look there for how to do it. For example https://mods.factorio.com/mod/LandfillEverything
Re: Edit blueprint in a mod
So if I have placeholder entity and I replace it with the another one, theoretically I can choose with the BluePrint the last one, but get the first one?
For example https://mods.factorio.com/mod/BurnerOffshorePump
Here is the pump (placeholder), they can define where the player can place the pump, but than I replace it with the assembling machine with recipe "water". How can I make them blueprintable?
Re: Edit blueprint in a mod
Setting the mining placed by field isn't enough?
Re: Edit blueprint in a mod
Can you please provide an example?
Re: Edit blueprint in a mod
Code: Select all
entity.placeable_by = item.name
entity.minable.result = item.name
Re: Edit blueprint in a mod
By rails it's a table, just adding the entity.placeable_by = item_name gets error.DaveMcW wrote: ↑Thu Nov 07, 2019 11:34 amCode: Select all
entity.placeable_by = item.name entity.minable.result = item.name
Code: Select all
data.raw["curved-rail"]["curved-rail"].placeable_by = {item = "rail", count = 4}
No, I cannot select the entity with "assembling_machine_entity.placeable_by = offshore_pump_item_name".
Re: Edit blueprint in a mod
Hi
Thanks for the answer.
I clearly overengineered my system, and the "placeably by" is the appropriate solution:
My situation is the same as Darkfrei: When placing an entity, the first entitiy E1 is replaced by a second E2 (E1 must be destroyed)
When blueprinting, E2 is taken in consideration. So, my blueprint contains E2
Then, if I define "minable.result" and placeably by from E2 for the item I,
-> When mining E2 (by robot or player)-> I got item I
-> By applying my blueprint, with E2, since E2 is placeably by I, an item I can be consumed to place E2
Though, I still don't see how to edit a blueprint via a mod. This could be very nice to add such content to the API.
But at least, this first problem is solved.
Many thanks for your help and advice, everyone
Niko
Thanks for the answer.
I clearly overengineered my system, and the "placeably by" is the appropriate solution:
My situation is the same as Darkfrei: When placing an entity, the first entitiy E1 is replaced by a second E2 (E1 must be destroyed)
When blueprinting, E2 is taken in consideration. So, my blueprint contains E2
Then, if I define "minable.result" and placeably by from E2 for the item I,
-> When mining E2 (by robot or player)-> I got item I
-> By applying my blueprint, with E2, since E2 is placeably by I, an item I can be consumed to place E2
Though, I still don't see how to edit a blueprint via a mod. This could be very nice to add such content to the API.
But at least, this first problem is solved.
Many thanks for your help and advice, everyone
Niko
Re: Edit blueprint in a mod
Did you make it selectable? Maybe share the complete prototype of the entities / items involved.darkfrei wrote: ↑Thu Nov 07, 2019 9:29 pmBy rails it's a table, just adding the entity.placeable_by = item_name gets error.DaveMcW wrote: ↑Thu Nov 07, 2019 11:34 amCode: Select all
entity.placeable_by = item.name entity.minable.result = item.name
UPDCode: Select all
data.raw["curved-rail"]["curved-rail"].placeable_by = {item = "rail", count = 4}
No, I cannot select the entity with "assembling_machine_entity.placeable_by = offshore_pump_item_name".
2019-11-07T22_40_57-Window.png
Re: Edit blueprint in a mod
I don't make it unselectable, so it's just
Code: Select all
local replacement_table = {
['offshore-pump'] = 'burner-offshore-pump',
['burner-offshore-pump-placeholder'] = 'burner-offshore-pump',
['electric-offshore-pump-placeholder'] = 'electric-offshore-pump'
}
function on_built_entity (event)
local ent = event.created_entity or event.entity
local name = ent.name
local bop_name = replacement_table[name] -- table with
if not bop_name then return else end
local surface = ent.surface
surface.create_entity{name=bop_name, position=ent.position, direction=ent.direction, force=ent.force, fast_replace=true, spill=false, raise_built=true, create_build_effect_smoke=false}
ent.destroy()
end
- Attachments
-
- BurnerOffshorePump_0.0.6.zip
- for 0.17
- (245.16 KiB) Downloaded 95 times
Last edited by darkfrei on Mon Nov 11, 2019 6:20 pm, edited 1 time in total.
Re: Edit blueprint in a mod
Interesting, but this small mod works as expected.
- Attachments
-
- small-burner-offshore-pump_0.0.1.zip
- for 0.17
- (32.65 KiB) Downloaded 106 times