Page 1 of 1

item.set_blueprint_entities() clears the mapping even when nothing changes

Posted: Thu Feb 20, 2025 5:47 pm
by Quezler
The on_player_setup_blueprint has a mapping, in the description it warns that it can become "incorrect":
Note: if any mod changes the blueprint this will be incorrect.
However this seems to suggest that if a mod adds/removes an entity to the blueprint that the numbers will simply not line up anymore / references entities that aren't in the blueprint anymore / lacks references to existing entities when they get added / etc

But it seems that even writing the same mapping back to the blueprint causes the mapping to become not just "incorrect", but outright completely empty:

Code: Select all

/c script.on_event(defines.events.on_player_setup_blueprint, function(event)
  local blueprint = event.stack
  if blueprint == nil then return end

  game.print("before: " .. serpent.block(event.mapping.get()))
  blueprint.set_blueprint_entities(blueprint.get_blueprint_entities())
  game.print("after: " .. serpent.block(event.mapping.get()))
end)
- start new world
- run command
- place your starting furnace
- ctrl c / blueprint it
- notice the second mapping being empty

It would be nice if it could be mentioned on this event that `set_blueprint_entities` will wipe the mapping and not just make it "incorrect", and on the set_blueprint_entities method a warning to only call if it you have modified the entities since "it can break stuff elsewhere if you write to it needlessly"

Re: item.set_blueprint_entities() clears the mapping even when nothing changes

Posted: Mon Feb 24, 2025 11:38 am
by Quezler
an extra remark:

i resorted to reading and writing the blueprint entities as a whole because "hey, its convenient and nothing warns me against it" even when all i did was edit blueprint entity tag since there was no apparent harm, if anything set_blueprint_entity_tag seemed like the "older/deprecated" method at the time whilst it is in fact the one you should be using when you only modify the tags, so a note that you should only use set_blueprint_entities when you add or remove entities would be nice.

https://github.com/Quezler/glutenfree/c ... 1a3924a4f4

Re: item.set_blueprint_entities() clears the mapping even when nothing changes

Posted: Mon Feb 24, 2025 5:01 pm
by curiosity
Note: if any mod changes the blueprint this will be incorrect.
This seems to need a clarification. Apparently set_blueprint_entity_tag doesn't count as changing the blueprint. What else doesn't? What does?