I need to store some data with an entity across blueprints. The solution seems to be to encode this as signals in a constant combinator. But then the alt-view will show the signals which I would rather avoid.
Can I turn the alt-view off for my custom constant-combinator in the prototype or something?
Saving entity data in blueprint but not showing signals in alt-view
Re: Saving entity data in blueprint but not showing signals in alt-view
Code: Select all
entity.flags = {"placeable-neutral", "player-creation", "hide-alt-info"}
Re: Saving entity data in blueprint but not showing signals in alt-view
Thanks, works like a charm.
-
- Filter Inserter
- Posts: 587
- Joined: Sun Jun 09, 2019 10:40 pm
- Contact:
Re: Saving entity data in blueprint but not showing signals in alt-view
Apparently `item-with-tags` is the forward-looking way to save custom data into blueprints. No idea if you can use it here, but it was mentioned by ... rposila IIRC ... as being the way to solve this. Conveniently it saves the same data that global can within the blueprint, so the data is definitely portable in the same way you store it internally.mrvn wrote: ↑Mon Sep 02, 2019 6:27 amI need to store some data with an entity across blueprints. The solution seems to be to encode this as signals in a constant combinator. But then the alt-view will show the signals which I would rather avoid.
Can I turn the alt-view off for my custom constant-combinator in the prototype or something?
Re: Saving entity data in blueprint but not showing signals in alt-view
Do you have an example of how to use this?slippycheeze wrote: ↑Wed Sep 04, 2019 6:50 pmApparently `item-with-tags` is the forward-looking way to save custom data into blueprints. No idea if you can use it here, but it was mentioned by ... rposila IIRC ... as being the way to solve this. Conveniently it saves the same data that global can within the blueprint, so the data is definitely portable in the same way you store it internally.mrvn wrote: ↑Mon Sep 02, 2019 6:27 amI need to store some data with an entity across blueprints. The solution seems to be to encode this as signals in a constant combinator. But then the alt-view will show the signals which I would rather avoid.
Can I turn the alt-view off for my custom constant-combinator in the prototype or something?
-
- Filter Inserter
- Posts: 587
- Joined: Sun Jun 09, 2019 10:40 pm
- Contact:
Re: Saving entity data in blueprint but not showing signals in alt-view
I am afraid that I do not. Setting and getting the tags is fairly obvious, using LuaItemStack.{get,set,remove}_tag(), and LuaItemStack.{get,set}_blueprint_entity_tag{,s}.mrvn wrote: ↑Sat Sep 07, 2019 2:41 pmDo you have an example of how to use this?slippycheeze wrote: ↑Wed Sep 04, 2019 6:50 pmApparently `item-with-tags` is the forward-looking way to save custom data into blueprints. No idea if you can use it here, but it was mentioned by ... rposila IIRC ... as being the way to solve this. Conveniently it saves the same data that global can within the blueprint, so the data is definitely portable in the same way you store it internally.mrvn wrote: ↑Mon Sep 02, 2019 6:27 amI need to store some data with an entity across blueprints. The solution seems to be to encode this as signals in a constant combinator. But then the alt-view will show the signals which I would rather avoid.
Can I turn the alt-view off for my custom constant-combinator in the prototype or something?
What I don't know enough about is how you would interface with the process of creating the blueprint to add your tags to the content. They will be placed on the ghost during construction, so you can read them when it is built, etc, from the item. Again, not certain exactly how that works, but I presume the appropriate event gets either the tag data as an argument, or a reference to an item/entity with the tag data.
If that doesn't get you where you need to, I'd suggest asking on the official discord, for the place I learned about this.
Re: Saving entity data in blueprint but not showing signals in alt-view
There is: defines.events.on_player_setup_blueprint
From the railloader mod I then have this example:
So I guess I have to catch that, iterate over all entities in the blueprint and for any of mine I have to use set_blueprint_entity_tag.
From the railloader mod I then have this example:
Code: Select all
local function on_blueprint(event)
local player = game.players[event.player_index]
local bp = player.blueprint_to_setup
if not bp or not bp.valid_for_read then
bp = player.cursor_stack
end
if not bp or not bp.valid_for_read then
return
end
local entities = bp.get_blueprint_entities()
if not entities then
return
end
...
end
Re: Saving entity data in blueprint but not showing signals in alt-view
Args, LuaItemStack.set_blueprint_entity_tag() was only added in 0.17.67. No wonder I never saw that before. Was 0.17.67 even out when I asked the question?