I want change some entity properties right before blueprinting, so this entity lay to blueprint with changes.
In event on_player_setup_blueprint I may access to entities, but its changing not stored in blueprint.
Has the way do something with it?
How to change entity before blueprinting
Re: How to change entity before blueprinting
The only one solution I made right now:
- get event.mapping
- get player.cursor_stack.get_blueprint_entities
- iterate mapping entities and change blueprint entities in same index praying for indexes is exactly similar.
- set blueprints entities back to cursor
This is working but seems shitty imho
- get event.mapping
- get player.cursor_stack.get_blueprint_entities
- iterate mapping entities and change blueprint entities in same index praying for indexes is exactly similar.
- set blueprints entities back to cursor
This is working but seems shitty imho
Re: How to change entity before blueprinting
You have found that the blueprint API only allows getting or setting the entire list of entities at once. That's how it's supposed to work.
I do this all the time when I want to change the name of the entity in the blueprint. As long as you're modifying entity subtables and not adding/subtracting from the number of entities, it's fine.
I do this all the time when I want to change the name of the entity in the blueprint. As long as you're modifying entity subtables and not adding/subtracting from the number of entities, it's fine.
My mods: Multiple Unit Train Control, Smart Artillery Wagons
Maintainer of Vehicle Wagon 2, Cargo Ships, Honk
Maintainer of Vehicle Wagon 2, Cargo Ships, Honk
Re: How to change entity before blueprinting
Indexes and values in tables event.mapping and player.cursor_stack.get_blueprint_entities is similar?
Re: How to change entity before blueprinting
Yes, that's right: https://lua-api.factorio.com/latest/eve ... _blueprint
It's not clear from the docs, but it seems to imply that if another mod's on_player_setup_blueprint code runs before yours, that the mapping might not be correct. I've never used the mapping table before, since I just read the entity name from the blueprint item entity list.mapping :: LuaLazyLoadedValue(dictionary[uint → LuaEntity])
The blueprint entity index to source entity mapping. Note: if any mod changes the blueprint this will be incorrect.
My mods: Multiple Unit Train Control, Smart Artillery Wagons
Maintainer of Vehicle Wagon 2, Cargo Ships, Honk
Maintainer of Vehicle Wagon 2, Cargo Ships, Honk