Saving entity data in blueprint but not showing signals in alt-view

Place to get help with not working mods / modding interface.
Post Reply
mrvn
Smart Inserter
Smart Inserter
Posts: 5704
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Saving entity data in blueprint but not showing signals in alt-view

Post 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?

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Saving entity data in blueprint but not showing signals in alt-view

Post by DaveMcW »

Code: Select all

entity.flags = {"placeable-neutral", "player-creation", "hide-alt-info"}

mrvn
Smart Inserter
Smart Inserter
Posts: 5704
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Saving entity data in blueprint but not showing signals in alt-view

Post by mrvn »

Thanks, works like a charm.

slippycheeze
Filter Inserter
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

Post 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.

mrvn
Smart Inserter
Smart Inserter
Posts: 5704
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Saving entity data in blueprint but not showing signals in alt-view

Post 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?

slippycheeze
Filter Inserter
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

Post 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.

mrvn
Smart Inserter
Smart Inserter
Posts: 5704
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Saving entity data in blueprint but not showing signals in alt-view

Post 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.

mrvn
Smart Inserter
Smart Inserter
Posts: 5704
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Saving entity data in blueprint but not showing signals in alt-view

Post 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?

Post Reply

Return to “Modding help”