Page 1 of 1
Saving entity data in blueprint but not showing signals in alt-view
Posted: Mon Sep 02, 2019 6:27 am
by mrvn
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?
Re: Saving entity data in blueprint but not showing signals in alt-view
Posted: Mon Sep 02, 2019 7:16 am
by DaveMcW
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
Posted: Mon Sep 02, 2019 8:06 am
by mrvn
Thanks, works like a charm.
Re: Saving entity data in blueprint but not showing signals in alt-view
Posted: Wed Sep 04, 2019 6:50 pm
by slippycheeze
mrvn wrote: Mon Sep 02, 2019 6:27 am
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?
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.
Re: Saving entity data in blueprint but not showing signals in alt-view
Posted: Sat Sep 07, 2019 2:41 pm
by mrvn
slippycheeze wrote: Wed Sep 04, 2019 6:50 pm
mrvn wrote: Mon Sep 02, 2019 6:27 am
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?
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.
Do you have an example of how to use this?
Re: Saving entity data in blueprint but not showing signals in alt-view
Posted: Mon Sep 09, 2019 5:26 pm
by slippycheeze
mrvn wrote: Sat Sep 07, 2019 2:41 pm
slippycheeze wrote: Wed Sep 04, 2019 6:50 pm
mrvn wrote: Mon Sep 02, 2019 6:27 am
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?
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.
Do you have an example of how to use this?
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}.
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
Posted: Tue Sep 10, 2019 11:19 am
by mrvn
There is: defines.events.on_player_setup_blueprint
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
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.
Re: Saving entity data in blueprint but not showing signals in alt-view
Posted: Tue Sep 10, 2019 11:59 am
by mrvn
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?